-2
rated 0 times
[
3]
[
5]
/ answers: 1 / hits: 45355
/ 13 Years ago, thu, august 18, 2011, 12:00:00
I have been using square bracket notation in Javascript to create and call associative arrays.
In this example, I understand that square bracket notation allows you to use a variable to call a certain object in the array.
How would you do something like this in dot notation?
var item = {};
item['1'] = 'pen';
var x = 1;
console.log(item[x]); // console will show 'pen'
More From » javascript