Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create a custom two-dimensional Array in javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 142
    Comment on it

    Hello friends,
    Most of time we need to create 2-D array in javascript but javascript does not provide direct syntax of multidimensional array . But we can create custom two-dimensional array in javascript.
    For Example :

    var myarray=new Array(3)
    for (i=0; i <3; i++)
        myarray[i]=new Array(3)
    

    First see the basic syntax of javascript .

    var myarray= new Array(3)

    myarray is a variable name and new is a keyword to create memory for array index. Now we create array on the index respectively then we get 2-D array. Like
    myarray[0][0]="Compaq 486"
    myarray[0][1]="Compaq 586"
    myarray[0][2]="Compaq 686"
    myarray[1][0]="Dell 486"
    myarray[1][1]="Dell 586"
    myarray[1][2]="Dell 686"
    myarray[2][0]="IBM 486"
    myarray[2][1]="IBM 586"
    myarray[2][2]="IBM 686"

 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: