console.log
将 WeakSet 显示为<items unknown>
?[13:37:11] [~] node
Welcome to Node.js v14.4.0.
Type ".help" for more information.
> let student1 = { name: 'James', age: 26 };
undefined
> let student2 = { name: 'Julia', age: 27 };
undefined
> const roster = new WeakSet([student1, student2]);
undefined
> console.log(roster);
WeakSet { <items unknown> }
undefined
上下文:我在 ES6中的WeakSet上遇到了以下示例。
let student1 = { name: 'James', age: 26 };
let student2 = { name: 'Julia', age: 27 };
const roster = new WeakSet([student1, student2]);
console.log(roster);
该示例表明它应该打印
WeakSet {Object {name: 'Julia', age: 27}, Object {name: 'Richard', age: 31}}
但在节点 v14.4.0 中,它会打印
WeakSet { <items unknown> }
www说
相关分类