Posted By

mlange on 10/03/06


Tagged

array


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

rmaltete
shachi


Arrays


 / Published in: JavaScript
 

[1] To create an array, use either the new Array() or [] syntax.

[2] In JavaScript, arrays and objects are almost equivalent, and accessing a named cell of an array is the same as accessing a property of an object. If a cell of an array is called 'mycell', you could use either of these to access its contents

[3] faked multidimensional arrays

  1. // ---------------------------------------------------------------
  2. // [1]
  3.  
  4. var nameOfArray = new Array();
  5. var nameOfArray = new Array('content_of_first_cell','and_the_second' 8,'blah','etc');
  6. var nameOfArray = ['content_of_first_cell','and_the_second',8,'blah','etc'];
  7.  
  8. // ---------------------------------------------------------------
  9. // [2]
  10.  
  11. nameOfArray['mycell']
  12. nameOfArray.mycell
  13.  
  14. // ---------------------------------------------------------------
  15. // [3]
  16.  
  17. var nameOfArray = new Array(new Array(1,2,3,4),'hello',['a','b','c']);
  18. nameOfArray[name_or_number_of_entry][name_or_number_of_inner_entry]

Report this snippet  

You need to login to post a comment.