for function js

JavaScript
var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) { 
  console.log(colors[i]);
}function range(start, end) {
	/* generate a range : [start, start+1, ..., end-1, end] */
	var len = end - start + 1;
	var a = new Array(len);
	for (let i = 0; i < len; i++) a[i] = start + i;
	return a;
}<?php
function writeMsg() {
    echo "Hello world!";
}

writeMsg(); //call the function
?>JavaScript For Loop: Summary
There are three types of for loops: the regular for loop, the for/in loop and for/of loop.
The for loop iterates through an array.
The for/in loop iterates through the properties of an object.
The for/of loop iterates through iterable objects, like arrays and strings.def function_name():
  pass/* Declare function */
function myFunc(param) {
  // Statements 
}
Source

Also in JavaScript: