for of object code example

Example 1: for each of object

Object.keys(object).map(function(objectKey, index) {
    var value = object[objectKey];
    console.log(value);
});

Example 2: use these instead of a for loop javascript

const array = [1, 2, 3];array.forEach(function(elem, index, array) {    array[index] = elem * 2;});console.log(array); // [2,4,6]

Example 3: use these instead of a for loop javascript

const array = [1,2,3,4,5];const evenNumbers = array.filter(function(elem) {   // expressions that return 'true' are retained   return elem % 2 == 0;});