In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use for of in es6", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use for of in es6" article.
In es6, "for of" is used to traverse data structures with the "Symbol.iterator" attribute deployed, and the "for of" loop is a method to traverse all data structures with the syntax "for (var value of data structure object) {console.log (value);}".
This tutorial operating environment: windows10 system, ECMAScript version 6. 0, Dell G3 computer.
What is the use of for of in es6
ES6 introduces the for...of loop as a unified method for traversing all data structures.
A data structure is considered to have an iterator interface as long as the Symbol.iterator attribute is deployed, and its members can be traversed with a for...of loop, that is, the Symbol.iterator method of the data structure is called inside the for...of loop.
The range that the for...of loop can use:
String
Array
Set and Map structure
Some array-like objects (such as arguments objects, DOM NodeList objects)
Generator object.
Use examples
Var arr = ['nick','freddy','mike','james']; for (var item of arr) {console.log (item);}
Output result:
Iterate through every item in the array.
Use examples
Var arr = [{name:'nick', age:18}, {name:'freddy', age:24}, {name:'mike', age:26}, {name:'james', age:34}]; for (var item of arr) {console.log (item.name,item.age);}
Output result:
Iterate through every item in the array.
The above is about the content of this article on "how to use for of in es6". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.