In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you the relevant knowledge about how to deal with the cycle in Javascript. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Case study:
Compute.exec () this is an asynchronous method that handles some actual business, and what is printed at this time is likely to be 300300300 (because the I value has been changed to 300300300 before the asynchronous operation returns the Promise object).
Function getMoney () {var money= [100200300] for (let item0; I {console.log (money [I]})}} 1. Async function getMoney () {var money= [100200300] for (let item0) I {console.log (money[ I]})} / / async tells getMoney that there is an asynchronous operation in the method / / await is placed in front of the specific asynchronous operation (method) It means waiting for the asynchronous return of Promise before continuing the following operation. 2. Recursive processing idea function getMoney (I) {var money= [100200300] compute.exec (). Then () = > {if (I < money.length) {console.log (moneyI]) ITunes; getMoney (I);}});} getMoney (0) / / start calling / / use recursion to implement the self-loop (the specific loop is in then to ensure that the asynchronous operation of the previous compute.exec () is completed). Then () is carried out after the Promise object is returned as resolve (you can learn about the Promise object). This is all the content of the article "how Javascript handles loops". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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.