美文网首页
关于ES6的entries()方法

关于ES6的entries()方法

作者: 泪滴在琴上 | 来源:发表于2022-05-06 11:35 被阅读0次
使用Object.entries(),Object.keys()和Object.values()
const obj = { a: 1, b: 2, c: 3 };

Object.entries(obj);
// 输出
(3) [Array(2), Array(2), Array(2)]
0: (2) ["a", 1]
1: (2) ["b", 2]
2: (2) ["c", 3]
length: 3

Object.keys(obj);
(3) ["a", "b", "c"]

Object.values(obj);
(3) [1, 2, 3]

相关文章

网友评论

      本文标题:关于ES6的entries()方法

      本文链接:https://www.haomeiwen.com/subject/dpdqertx.html