locked
arrays in javascript RRS feed

  • Question

  • hi,

    i want jagged array type array in javascript.i dont know how to create it in javascript  can any body     plz help.........


    vvs

    Thursday, May 3, 2012 7:06 AM

Answers

  • hi vidyasagar,

    var obj = [];
    obj.push([1, 2, 3])
    obj.push([4, 5]);  
    


    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    Thursday, May 3, 2012 7:19 AM
  • hi ,

    You can use as below

    cats = [{color: "brown", size: "large"}, {color: "black", size: "small"}];
    cats[0]["size"];      // results in "large"

    dogs = {rover: {color: "brown", size: "large"}, spot:  {color: "black", size: "small"}};
    dogs["spot"]["size"]; // results in "small"
    dogs.rover.color;     // results in "brown"


    Monday, May 7, 2012 4:06 AM
  • Pls have a look at the following link.

    http://stackoverflow.com/questions/5939504/how-to-initialize-a-jagged-array-in-javascript


    Always mark the answers if the post answers your question. Prabhu R

    Monday, May 7, 2012 5:59 AM

All replies

  • hi vidyasagar,

    var obj = [];
    obj.push([1, 2, 3])
    obj.push([4, 5]);  
    


    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    Thursday, May 3, 2012 7:19 AM
  • hi ,

    You can use as below

    cats = [{color: "brown", size: "large"}, {color: "black", size: "small"}];
    cats[0]["size"];      // results in "large"

    dogs = {rover: {color: "brown", size: "large"}, spot:  {color: "black", size: "small"}};
    dogs["spot"]["size"]; // results in "small"
    dogs.rover.color;     // results in "brown"


    Monday, May 7, 2012 4:06 AM
  • Pls have a look at the following link.

    http://stackoverflow.com/questions/5939504/how-to-initialize-a-jagged-array-in-javascript


    Always mark the answers if the post answers your question. Prabhu R

    Monday, May 7, 2012 5:59 AM