Ale*_*nik 8 javascript set ecmascript-6
我刚刚浏览了set的 MDN 文档,以及它是如何工作的,来到如何迭代 set 的部分,我看到了以下示例:
// logs the items in the order: 1, "some text", {"a": 1, "b": 2}
for (let item of mySet) console.log(item);
Run Code Online (Sandbox Code Playgroud)
和
// logs the items in the order: 1, "some text", {"a": 1, "b": 2}
for (let item of mySet.values()) console.log(item);
Run Code Online (Sandbox Code Playgroud)
和
// logs the items in the order: 1, "some text", {"a": 1, "b": 2}
//(key and value are the same here)
for (let [key, value] of mySet.entries()) console.log(key);
Run Code Online (Sandbox Code Playgroud)
只是为了确认,这是否意味着使用 set 时键和值是相同的?