JavaScript/set:修订间差异
来自康健生活
| 第19行: | 第19行: | ||
size: 6 | size: 6 | ||
[[Prototype]]: Set | [[Prototype]]: Set | ||
</pre>}}}} | |||
== 格式转换 == | |||
=== set 转 array === | |||
{{leftrightflex|<syntaxhighlight lang="javascript"> | |||
const _set = new Set([1, 2, 3]); | |||
console.log(Array.from(_set));</syntaxhighlight>|{{consoleout|<pre> | |||
[ 1, 2, 3 ] | |||
</pre>}}}} | </pre>}}}} | ||