Object.fromEntries

var obj = {
	a: 1,
  b: 2
}
Object.prototype.c = 3;

var objArr = Object.entries(obj);
var newObj = Object.fromEntries(objArr);

console.log(obj === newObj);

Untitled

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);

Untitled

实现

Object.prototype.myFromEntries = function(obj) {
  var _obj = {};
  
  for (var item of obj) {
  	_obj[item[0]] = item[1];
  }
  
  return _obj;
}