javascript let in for loop code example

Example 1: javascript for of

const array = ['hello', 'world', 'of', 'Corona'];

for (const item of array) {
  console.log(item);
}

Example 2: for in javascript

for (let i = start; i < end; i++) {

}

Example 3: how to use for of in javascript

const array1 = ['a', 'b', 'c'];

for (const element of array1) {
  console.log(element);
}

Example 4: 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;});