Created
February 28, 2021 13:46
-
-
Save mohanramphp/0767c405d61f4b23c9a7a3a2c716bca8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const students = ["Mohan", "Ram", "Jeeva", "Priya"]; | |
//since students object is an iterable, we can use with iteration mechanism such as for, spread operators etc. | |
for (let student of students) { | |
console.log(student); | |
} | |
// prints | |
// "Mohan" | |
// "Ram" | |
// "Jeeva" | |
// "Priya" | |
console.log(...students); // Mohan Ram Jeeva Priya | |
const employees = {}; | |
for (let employee of employees) { | |
console.log(employee); | |
} | |
// Uncaught TypeError: employees is not iterable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment