Select Page
JavaScript ES6+ : For Of Loops
Jayman Pandya
Apr 17, 2020

For Of loops are new in Javascript and can be used to loop on any kind of iterable data except object.

Iterable data are Arrays, String, Map, Set, Generator etc. For Of loop does not loop over other properties of the prototype and other methods. It also allows us to interrupt the loop by using ‘break’ & ‘continue’ commands.

const kidsUsingTheFacilityRightNow = ['Megan', 'Roy', 'James', 'Louis'];
for (const kidUsingTheFacilityRightNow of kidsUsingTheFacilityRightNow) {
if (kidUsingTheFacilityRightNow === 'James') {
continue;
}
console.log(kidUsingTheFacilityRightNow);
}

Peace ✌️

Let's Talk

If you liked what you have seen, then let’s connect and make something amazing together.

Email me at converse@jaymanpandya.com or send a DM on my twitter @jaymanpandya