1. 程式人生 > >js map新增刪除key,及其key列表

js map新增刪除key,及其key列表

var map = {};
map["a"] = 1;
map["b"] = 2;

console.log(Object.keys(map));    //[ 'a', 'b' ]
console.log(map);                 //{ a: 1, b: 2 }
delete map["a"];                  
console.log(map);                 //{ b: 2 }
console.log(Object.keys(map));    //[ 'b' ]