ES6对象

---------------------------------------------------------------------

对象的扩展

let obj = {a: 1, b: 2, c: 3, d: 4};

Object.keys(obj).forEach((key,index)=>{ console.log(key); });

// d

===============================

let obj = {a: 1, b: 2, c: 3, d: 4};

Object.values(obj).forEach((value,index)=>{ console.log(value); });

// 1 2 3 4

=================================

let obj = {a: 1, b: 2, c: 3, d: 4};
Object.entries(obj).forEach((entry,index)=>{
console.log(entry);
});
// ["a", 1] ["b", 2] ["c", 3] ["d", 4]

原文地址:https://www.cnblogs.com/moneyss/p/10637174.html