ES6 Set vs ES5 Array
ES6 Set vs ES5 Array
Set
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
const set = new Set()
// undefined
set.add(1)
// Set(1) {1}
set.add('some text')
// Set(2) {1, "some text"}
set.has(3)
// false
set.add(3);
// Set(3) {1, "some text", 3}
set.delete(2);
// false
set.delete(3);
// true
set[0];
// undefined
set.size;
// 2
Set 转换成 Array
const arr = [...set];
// undefined
arr;
// (2) [1, "some text"]
Map 转换成 Object
https://www.cnblogs.com/xgqfrms/p/13756665.html
refs
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13757290.html
未经授权禁止转载,违者必究!