InterviewSolution
Saved Bookmarks
| 1. |
What is the difference between for..of and for..in? |
Answer»
Both the for..of and for..in commands ITERATE over lists, but the RESULTS they return are different: for..in returns a list of keys on the object being iterated, whereas for..of returns a list of values of the object's numeric attributes. let arr = [3, 4, 5];for (let i in arr) { console.log(i); // "0", "1", "2",}for (let i of arr) { console.log(i); // "3", "4", "5"} |
|