js 取对象值

const peopleArray = Object.keys(peopleObj).map(i => peopleObj[i])
-------

const object1 = {
a: 'somestring',
b: 42,
c: false
};

console.log(Object.keys(object1));
// expected output: Array ["a", "b", "c"]

------

const object1 = {
a: 'somestring',
b: 42,
c: false
};

console.log(Object.values(object1));
// expected output: Array ["somestring", 42, false]

 

-----

const object1 = { foo: 'bar', baz: 42 };
console.log(Object.entries(object1)[1]);
// expected output: Array ["baz", 42]

posted @ 2018-11-16 19:51  yt风往南吹  阅读(184)  评论(0编辑  收藏  举报