Reputation: 11829
var objs = {
'prop': []
}
objs['prop'].append('q');
Error: TypeError: objs.prop.append is not a function
Why this code is not working ?
Why console.log(typeof(objs['prop']));
is object
not array
?
Upvotes: 3
Views: 14478
Reputation: 82594
var objs = {
'prop': []
}
objs['prop'].append('q');
should be:
var objs = {
'prop': []
}
objs['prop'].push('q');
Upvotes: 13
Reputation: 174957
Because there are no associative arrays in JavaScript, an associative array is actually an Object. Nothing more nothing less.
Upvotes: 3