Description and usage of for...of Loop in javascript
This article introduces the relevant knowledge of "the explanation and use of the for...of cycle in javascript". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. ES6 adds a for..of loop for iterating objects, which requires that objects must be iterated.
The object must meet the iterable protocol.
2. Available ranges include arrays, Set and Map structures, array objects, Generator objects, and strings.
Example
Const arr = ['red',' green', 'blue']; for (let v of arr) {console.log (v); / / red green blue} const obj = {}; obj [Symbol.iterator] = arr [Symbol.iterator] .bind (arr); for (let v of obj) {console.log (v); / / red green blue} "instructions and usage of for...of cycle in javascript" ends here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!