javascript foreach object keys

JavaScript
var lunch = {
	sandwich: 'ham',
	snack: 'chips',
	drink: 'soda',
	desert: 'cookie',
	guests: 3,
	alcohol: false,
};

Object.keys(lunch).forEach(function (item) {
	console.log(item); // key
	console.log(lunch[item]); // value
});

// returns "sandwich", "ham", "snack", "chips", "drink", "soda", "desert", "cookie", "guests", 3, "alcohol", false
const object1 = {
  a: 'somestring',
  b: 42,
  c: false
};

console.log(Object.values(object1));
// expected output: Array ["somestring", 42, false]const obj = {
  a: "aa",
  b: "bb",
  c: "cc",
};
//This for loop will loop through all keys in the object.
// You can get the value by calling the key on the object with "[]"
for(let key in obj) {
  console.log(key);
  console.log(obj[key]);
}

//This will return the following:
// a
// aa
// b
// bb
// c
// ccfor (var prop in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, prop)) {
        // do stuff
    }
}
Source

Also in JavaScript: