const obj = {name: 'sifan', age: 22}
- object.keys(obj) // 获取可枚举属性
Object.keys(obj) // ['name', 'age']
- Object.values(obj) // 获取可枚举值
Object.values(obj) // ['sifan', 22]
- Object.entries(obj) // 返回对象的键值对
Object.entries(obj) // [['name', 'sifan'], ['age', 22]]
- Object.formEntries() // entries的反操作,将键值对的数组转换为对象
Object.formEntries(Object.entries(obj)) // {name: 'sifan', age: 22}
- delete // 删除对象的属性,返回true
delete obj.name // true
obj // {age: 22}
标签:常用,obj,name,22,对象,age,Object,entries,方法
From: https://www.cnblogs.com/taosifan/p/16857964.html