JAVASCRIPT YOU DONT KNOW JS CODE
I think this example is still very vivid, ha ha. Code Preview You Dont Know JS Yet (book series) - 2nd Edition.
JAVASCRIPT YOU DONT KNOW JS HOW TO
After I get it, I can choose to eat it or throw it away (which is impossible, of course)( This shows that it is up to us to decide how to realize it) Boxing wasn’t considered coercion in an accurate sense. If the hamburger is ready, I will go and get my hamburger. In You Don’t Know JS the Coercion Chapter I’ve read that with coercion, you never get result that is a complex value, like an object or an array. At this point, I need to consider changing other foods. At this time, I just had to sit and wait for my order number from miss( At this time, a promise has been generated)During the waiting time, we can do some other things, such as making phone calls, playing with mobile phones, talking about work, etc( This is the reasonable use of the gap time, which can be fully reflected in the asynchronous JS, but it is not within the scope of this article)Until the Miss calls the XX number( A promise execution ends), There are generally two resultsEither Hamburger is ready( The value set in resolve() in promise)Either Hamburgers are sold out(the value set in reject() in project). With this book you will: Learn the essential programming building blocks, including operators, types, variables. This morning, I went to buy breakfast and went to a fast food restaurant, Ordered a hamburger( Made a request)I’m right at the cash register Paid for this hamburger( It is similar to the passing of parameters)But I didn’t get the hamburger immediately. By learning the basic building blocks of programming, as well as JavaScript’s core mechanisms, you’ll be prepared to dive into the other, more in-depth books in the seriesand be well on your way toward true JavaScript. Promise is a kind of normal form。 Here is a quote: A callback is to give our encapsulated callback function to a third party (or even external code), and then we expect it to call our encapsulated callback function。 So promise is Instead of passing on our own program to a third party, the third party gives us when the task will end, and then we decide what to do next。 (PS: OK, New date() - Sat 23:55:17 GMT + 0800 (China standard time)After writing, wash and sleep) Promise What is promise In the history of JavaScript asynchronous programming, I think there are three ways of asynchronous programmingīecause I don’t want to remember a long time ago, was Back to hellThe fear of domination is to skip the callback part, and readers can understand it by themselves (limited space) However, due to the increasing demands of developers for JavaScript and the complexity of the project, especially the management of asynchronism is becoming more and more painful, all of which lead to the urgent need for more powerful and reasonable asynchronous methods to help us manage the asynchronous state. About JavaScriptThis language, in fact, I prefer to call it ECMAScriptFrom the beginning, we have been involved in asynchronous programming, but most JavaScript developers have never seriously thought about how asynchrony is implemented in their programs, and why they appear.