6 ways to operate asynchronously in JavaScript

6 ways to operate asynchronously in JavaScript.

1 Callback function: callback
2 Event listening: onXxxx, addEventListener.
3 Pub/Sub (Design Mode)

4 Promises are a solution to asynchronous programming that is more reasonable and powerful than traditional solutions – callback functions and events. It was first proposed and implemented by the community, and ES6 wrote it into the language standard, unified usage, and natively provided a Promise object

5 Generator functions are an asynchronous programming solution provided by ES6, and the syntax behavior is completely different from traditional functions, and the Generator function takes JavaScript asynchronous programming to a whole new stage.

6 async functions: The ES2017 standard introduces async functions to make asynchronous operations more convenient. What is the async function? In a word, it is the syntactic sugar of the Generator function.

Of course .timers and ajax can also be seen as .


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *