entry类型的对象
Introduced in ES2017
.
在ES2017
中ES2017
。
This method returns an array containing all the object own properties, as an array of [key, value]
pairs.
此方法以[key, value]
对的数组形式返回一个包含所有对象自身属性的数组。
Usage:
用法:
const person = { name: 'Fred', age: 87 }
Object.entries(person) // [['name', 'Fred'], ['age', 87]]
Object.entries()
also works with arrays:
Object.entries()
也可用于数组:
const people = ['Fred', 'Tony']
Object.entries(people) // [['0', 'Fred'], ['1', 'Tony']]
You can use it to count the number of properties an object contains, combined with the length
property of the array.
您可以使用它来计算对象包含的属性数量,以及数组的length
属性。
entry类型的对象