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

对象的扩展

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]

相关文章:

  • 2021-06-09
  • 2022-03-04
  • 2021-10-07
  • 2021-11-26
  • 2021-10-08
  • 2021-06-16
  • 2021-10-23
猜你喜欢
  • 2022-03-09
  • 2022-12-23
  • 2021-04-20
  • 2021-11-16
  • 2021-12-12
  • 2022-12-23
相关资源
相似解决方案