Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 0.34 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do associative arrays work in JavaScript?
  2. myArray['value'] = 10;
  3. myArray['another_key'] = 11;
  4.        
  5. myArray[0][0] = 'value';
  6. myArray[0][1] = 10;
  7. myArray[1][0] = 'another_key';
  8. myArray[1][1] = 11;
  9.        
  10. var a = [];
  11. a['foo'] = 'bar';
  12. console.log(a.length) // prints 0
  13.        
  14. var a = [];
  15. a[0] = 42;
  16.        
  17. myArray.value = 10;
  18. myArray.another_key = 11;