for of loop was introduced in ES6 which allows you to easily iterate over elements of an collection.for of iterates over the values of elements of a collection not the keys. A collection can be an array, set, list, custom collection object etc.
Earlier to ES6 we had to use for loop or Array�s foreach loop to walkthrough elements of an collection. ES6 introduced a new way for iteration.
Syntax
Example
Example Program:- (Editor)

Editor is Loading...
Advertisement
Tags:
Earlier to ES6 we had to use for loop or Array�s foreach loop to walkthrough elements of an collection. ES6 introduced a new way for iteration.
Syntax
for (variable of array_or_object)
{
Statements;
}Example
var ar = [2, 4, 5, 2, 7, 48, 234];
for (i of ar)
{
alert(i);
} Example Program:- (Editor)
Editor is Loading...
Advertisement
RSS Feed
Twitter
03:54
Muhammad Kaif

Posted in
0 comments:
Post a Comment