Javascript Foreach
This tutorial explains For loop in Javascript which is much like foreach in PHP:
Javascript For each Syntax:
var loop = ["javascript_element1", "javascript_element2", "javascript_element3"]; for ( var i in loop ) { alert( loop[i] ); }
In the example above, we iterate through each of the loop variable and alert for each element in the javascript array. The javascript foreach allows us to not keep track of the length of the array, since, now foreach is iterating through each element in the loop variable.

Post Comment