Skip to content

JS Array 和 Set 相互转换

Published: at 01:49 PMSuggest Changes

array —> set

let array = [1, 2, 3, 4];
let set = new Set(array);

set —> array

let demo = new Set([1, 2, 3, 4]);
Array.from(demo);

Previous Post
提取 CODEIF 核心代码片段
Next Post
JS 遍历对象所有 key 并转成数组