JS中构造一个map

JS中构造一个map

构造一个map

let map = {};
map[17] = "x1";
map[26] = "x2";
console.log(map[26])

map的遍历

for(let key in map) {
    console.log(key);
    console.log(map[key]);
}

一个看上去没什么用的鸡肋方法

var list = [
    {
        id: 11,
        name: "zhangsan",
        age: 34
    },
    {
        id: 399,
        name: "lisi",
        age: 16
    },
];
var x = list.map(r=>{
    return {
        name: r.name,
        age: r.age
    }
})
console.log(x);
posted @ 2022-05-21 11:35  陆敏技  阅读(450)  评论(0编辑  收藏  举报
Web Counter
Coupon for Contacts