theonlychase
9/28/2018 - 12:47 AM

Object.keys()

Gives us an array of all the keys in the object

var apple = {color: 'red', size: 'big', fruit: true };
var arr = Object.keys(apple);
console.log(arr);

for (prop of Object.keys(apple)) { //Object.keys() Gives us an array of all the keys in the object ["color, size", "weight", "sugar"];
  const value = apple[prop]; //Gives us the value
  console.log(value, prop);
}