xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

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 发布文章使用:只允许注册用户才可以访问!


posted @ 2020-10-01 09:12  xgqfrms  阅读(138)  评论(1编辑  收藏  举报