ES6 Map All In One_ES6 ES6 Map All In One 二维数组 字典



ES6 Map All In One

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))



ES6 Map All In One_ES6



​ ​