Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction and usage of yield keyword in javascript

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "introduction and use of the yield keyword in javascript". The explanation in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "the introduction and use of the yield keyword in javascript".

1. The yield keyword can only be used in the generator function, which means to pause the execution of the internal code of the function and return the current iteration data.

2. If there is no next yield,next, the done of the returned object will be placed as true.

After the yield keyword, the result of the expression returns the value as next.

Example

Def foo (): print ("starting...") While True: res = yield 4 print ("res:", res) g = foo () print (next (g)) print ("*" * 20) print (next (g)) Thank you for your reading. This is the content of "introduction and use of the yield keyword in javascript". After studying this article, I believe you have a deeper understanding of the introduction and use of the yield keyword in javascript. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report