我有这个代码作为例子:
const wolf = { type: 'canine', } const pug = Object.create(wolf, { size: { value: 's' } }); console.log(pug.hasOwnProperty('size')); // true
Chrome输出:
console.log(pug); // {size: 's'}
NodeJS 19.0.0输出:
console.log(pug); // {}
vhmi4jdf1#
当对象输出到控制台时,只显示可枚举属性:
> Object.create(wolf, {size: {value: "s", enumerable: true}}) { size: 's' } > Object.create(wolf, {size: {value: "s"}}) {}
1条答案
按热度按时间vhmi4jdf1#
当对象输出到控制台时,只显示可枚举属性: