Iterating over an array myarray=[1, 2, 3]
works like this:
[[item]]<
Revisiting this to account for issues others have mentioned. This is compatible with all browsers and uses hasOwnProperty
.
key: [[item.key]] val: [[item.val]]
...
_toArray: function(obj, deep) {
var array = [];
for (var key in obj) {
if (deep || obj.hasOwnProperty(key)) {
array.push({
key: key,
val: obj[key]
});
}
}
return array;
}