四. 对象方法的扩展

// 声明对象
const school = {
    name: "上海华师大",
    cities: ['上海','北京','深圳'],
    skill: ['java','php','vue']
}

Object.keys(school)                  //  ["name", "cities", "skill"]

Object.values(school)               //  ["上海华师大", Array(3), Array(3)]

Object.entries(school)              // [ ["name", "上海华师大"]
                                         ["cities", Array(3)]
                                         ["skill", Array(3)]
                                        ]

new Map(Object.entries(school))     // Map(3) {"name" => "上海华师大", "cities" => Array(3), "skill" => Array(3)}

const m = new Map(Object.entries(school))

m.get('cities')                     // ["上海", "北京", "深圳"]

Object.getOwnPropertyDescriptors(school)

四. 对象方法的扩展

上一篇:Spring基础入门文章


下一篇:Distributing Custom Apps