python dict.items , , dict. Javascript , .
python, .
>>> {1:2, 2:3}.items()
[(1, 2), (2, 3)]
>>> {1:2, 2:3}.values()
[2, 3]
, , python dict.values. dict.items. 2 .
function items(obj){
var ret = [];
for(v in obj){
ret.push(Object.freeze([v, obj[v]]));
}
return Object.freeze(ret);
}
Object.freeze , , python. , , .
, items , , , - . , , , , , javascript.
- Object.entries(), , .
Object.entries({1:1, 2:2, 3:3})
.forEach(function(v){
console.log(v)
});
, .