4️⃣

4.4 For Of Loop

4.4 For Of Loop

For of loops goes through the values of an iterable object (ex. Arrays).
💡
A list of iterable objects won't be listed here, so your just going to have to Google them.

Example

let basket = ['apple', 'grapes', 'banana'] // array - for now, think of this as a list for (let fruit of basket) { // prints out all the fruits in the basket console.log(fruit); }
💡
You could also accomplish this with a regular loop. However, this loop guarantees that you go through all the values in the array and is just cleaner and shorter.
 
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.