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
?
var objs = {
'prop': []
}
objs['prop'].append('q');
should be:
var objs = {
'prop': []
}
objs['prop'].push('q');
Because there are no associative arrays in JavaScript, an associative array is actually an Object. Nothing more nothing less.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.