Answers for "for of with object"

10

object for loop

const object = {a: 1, b: 2, c: 3};

for (const property in object) {
  console.log(`${property}: ${object[property]}`);
}
Posted by: Guest on April-10-2020
2

js for in object

var obj = { foo: 'bar', baz: 42 };
console.log(Object.entries(obj)); // [ ['foo', 'bar'], ['baz', 42] ]

for(const [i, val] of Object.entries(obj))
	new_obj[i] = val;
Posted by: Guest on February-10-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language