javascript for const code example

Example 1: javascipr for of

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

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

// expected output: "a"
// expected output: "b"
// expected output: "c"

Example 2: for of loop in es6

let colors = ['Red', 'Blue', 'Green'];
for (let color of colors){
	console.log(color);
}

Example 3: const in javascript

const value = 10;
const constant = value;

Example 4: how to create a constant in javascript

const example1 = "hello this is string variable" ; //this is string constant
const example2 = 12345 ; //this is numeric constant
const example3 = true ; //boolean constant

Tags:

Misc Example