Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • JavaScript Initializing Arrays

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 115
    Comment on it

    How to create an array in JavaScript?

    Before going for the above question we should be clear about What is an Array?

    An array is a sequential collection of variables or we can say an array is a special variable, which can hold more than one value at a time.

    You can create an array using either

    • an array initializer (array literal)

      example:

      var Arr1 = [1,3,5,7,9]
      
    • or the Array constructor.

      example:

      var Arr1 = new Arr(1,3,5,7,9)  // an array with 5 elements
      

    How to access the Elements of an Array

    To refer an array element can be done by referring to the index number.

    This statement accesses the value of the first element in Arr1: var element = Arr1[0]

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: