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

ES6 Map All In One

ES6 Map All In One

Map 字典/地图

Set 集合

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set

Map with initializing

initial value

// ✅ 二维数组,作为初始值 
const map = new Map([["(", ")"]]);
// Map(1) {"(" => ")"}

const map = new Map(["(", ")"]);
// ❌  Uncaught TypeError: Iterator value ( is not an entry object  at new Map (<anonymous>)

const map = new Map({"(": ")"});
// ❌ Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))



refs

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Cloning_and_merging_Maps



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2020-11-18 12:20  xgqfrms  阅读(122)  评论(1编辑  收藏  举报