1//ES6 Object to Array
2
3const numbers = {
4 one: 1,
5 two: 2,
6};
7
8console.log(Object.values(numbers));
9// [ 1, 2 ]
10
11console.log(Object.entries(numbers));
12// [ ['one', 1], ['two', 2] ]
1var object = {'Apple':1,'Banana':8,'Pineapple':null};
2//convert object keys to array
3var k = Object.keys(object);
4//convert object values to array
5var v = Object.values(object);
1const numbers = {
2 one: 1,
3};
4
5const objectArray = Object.entries(numbers);
6
7objectArray.forEach(([key, value]) => {
8 console.log(key); // 'one'
9 console.log(value); // 1
10});
11
1const numbers = {
2 one: 1,
3};
4
5const objectArray = Object.entries(numbers);
6
7objectArray.forEach(([key, value]) => {
8 console.log(key); // 'one'
9 console.log(value); // 1
10});
1
2
3
4
5 const propertyValues = Object.values(person);
6
7console.log(propertyValues);
8
1const entries = Object.entries(person);
2
3console.log(entries);
4Code language: JavaScript (javascript)