From the course: Learning ECMAScript 6+ (ES6+)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Iterating with the for/of loop - JavaScript Tutorial
From the course: Learning ECMAScript 6+ (ES6+)
Iterating with the for/of loop
- [Instructor] For/of is a new iteration syntax that we can use to replace for in and for each. Now, we can use this to loop over iterable objects, like arrays, strings, maps and sets. So let's go ahead and loop over a string. So we're going to say for and we'll say let letter of JavaScript and then for each letter in JavaScript, we'll log it to the console. So we see all of these different letters being added to the console on their own line. An array is also iterable. So we can create a variable called topics and set that equal to an array of JavaScript, Node and CSS. Now when we iterate over the topics, we can log each topic to the console. And we see all of them being added here at the bottom. So instead of using the array for topics, we're going to go ahead and create a new map and then we'll use the set function to define a key, which will be HTML. And a route where we can find more information about it. So…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Enhancing object literals2m 8s
-
(Locked)
Creating objects with the spread operator1m 25s
-
(Locked)
Destructuring objects3m 2s
-
(Locked)
Iterating with the for/of loop2m 40s
-
(Locked)
Introducing classes2m 28s
-
(Locked)
Inheritance with JavaScript classes1m 39s
-
(Locked)
Getting and setting class values3m 35s
-
(Locked)
-
-
-