导航
var obj = {
a: 1,
b: 2
}
Object.prototype.c = 3;
var objArr = Object.entries(obj);
var newObj = Object.fromEntries(objArr);
console.log(obj === newObj);
var obj = {
a: 1,
b: 2
}
Object.prototype.c = 3;
var objArr = Object.entries(obj);
var map = new Map(objArr);
var newObj = Object.fromEntries(map);
console.log(newObj);
Object.prototype.myFromEntries = function(obj) {
var _obj = {};
for (var item of obj) {
_obj[item[0]] = item[1];
}
return _obj;
}