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
0 nhận xét:
Đăng nhận xét