1var person={
2 first_name:"johnny",
3 last_name: "johnson",
4 phone:"703-3424-1111"
5};
6for (var property in person) {
7 console.log(property,":",person[property]);
8}
1let obj = {
2 key1: "value1",
3 key2: "value2",
4 key3: "value3"
5}
6
7Object.keys(obj).forEach(key => {
8 let value = obj[key];
9 //use key and value here
10});
1var cars = [{name: 'Audi'}, {name: 'BMW'}, {name: 'Ferrari'}, {name: 'Mercedes'}, {name: 'Maserati'}];
2
3for(var i = 0; i < cars.length; i++) {
4 console.log(cars[i].name);
5}
1const myArray = [{x:100}, {x:200}, {x:300}];
2
3myArray.forEach((element, index, array) => {
4 console.log(element.x); // 100, 200, 300
5 console.log(index); // 0, 1, 2
6 console.log(array); // same myArray object 3 times
7});
8