Possible Duplicate:
Length of Javascript Object (ie. Associative Array)
Loop through JavaScript object
var location = {
"Steve": "New York",
"Abigayle": "Chicago"
}
for (var i = 0; i < location .length; i++)
{
console.log('works');
}
I'm trying to make an array, where each item has some name and value.
The code above doesn't work. Tryed to make an object, but it doesn't have a length
property - no for
loop.
location= {
"Steve": "New York",
"Abigayle": "Chicago"
};
Is it possible to use arrays in this context?