HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The JavaScript for of statement loops through the values of an iterable object
The JavaScript for of
statement loops
through the values of an iterable object.
It lets you loop over iterable data structures such as Arrays, Strings, Maps, NodeLists, and more:
for (variable of iterable) {
// code block to be executed
}
const
, let
, or var
.
Safari 7 was the first browser to support for of:
Chrome 38 | Edge 12 | Firefox 51 | Safari 7 | Opera 25 |
Oct 2014 | Jul 2015 | Oct 2016 | Oct 2013 | Oct 2014 |
const cars = ["BMW", "Volvo", "Mini"];
let text = "";
for (let x of cars) {
text += x;
}
let language = "JavaScript";
let text = "";
for (let x of language) {
text += x;
}
The while
loop and the do/while
loop are explained in the next chapter.