JavaScript Asynchronous Programming asynchronous Js:callbacks, Listeners, Control Flow Libs and Promises

Source: Internet
Author: User

The JavaScript language execution environment is "single thread"

Only one task can be completed at a time. If you have multiple tasks, you must queue, complete the previous task, and then perform the latter task

The JavaScript language divides the execution pattern of a task into two types: synchronous (synchronous) and asynchronous (asynchronous)

"Asynchronous mode" is completely different, each task has one or more callback functions (callback), after the end of the previous task, not after the execution of a task, but the execution of the callback function, the latter task is not equal to the end of the previous task is executed, so the order of execution of the program is inconsistent with the order of the task, Asynchronous.

4 Ways to Program "asynchronous mode"

First, the callback function

Second, event monitoring

Third, publish/Subscribe

Iv. promises objects

JavaScript Asynchronous Programming asynchronous Js:callbacks, Listeners, Control Flow Libs and Promises

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.