ES2017 keys,values,entries使用

let {keys, values, entries} = Object;
let obj = { a: 1, b: 2, c: 3 }; for (let key of keys(obj)) {
console.log(key); // 'a', 'b', 'c'
} for (let value of values(obj)) {
console.log(value); // 1, 2, 3
} for (let [key, value] of entries(obj)) {
console.log([key, value]); // ['a', 1], ['b', 2], ['c', 3]
}

Object.keys可以省略Object.

上一篇:MB SD Connect 5 vs 2017 FVDI2 Commander


下一篇:CSS3中哪些新属性—阴影、文本省略(1)