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

What does javascript synchronization mean?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This "javascript synchronization refers to what means" article, the article sample code is introduced in great detail, with a certain reference value, interested friends must refer to, for "javascript synchronization refers to what is the meaning", Xiaobian collated the following knowledge points, please follow the pace of the editor step by step slowly understand, then let us enter the topic.

In JavaScript, synchronization means that the last task is executed after the end of the previous task, and the execution order of the program is synchronized with the order of the tasks. A major feature of the JS language is single-threaded, which can only do one thing at a time, which means that the next thing can only be done after one thing is over.

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

What does javascript synchronization mean?

A major feature of S language is single thread, which can only do one thing at a time. It means that you can't move on to the next until one thing is over.

HTML5 proposes the Web Worker standard, which allows JavaScript scripts to create multiple threads. So there is synchronization and asynchronism.

Synchronization:

When the last task is executed after the end of the previous task, the execution order of the program is consistent and synchronized with the order of the tasks.

Async:

You can deal with other events while doing one thing.

Synchronous and asynchronous console.log ('first statement'); setTimeout (function () {console.log ('second statement');}, 5000) console.log ('third statement')

When outputting the results, the first statement is displayed first, then the third statement, and the second statement is displayed after waiting for 5 seconds.

The difference between synchronous and asynchronous is that each process is executed in a different order on the pipeline.

What kind of printing order will it be when the timer time is 0? Change the timer time of the above program to 0, execute the program, and find that the output order has not changed.

JS divides all tasks into two categories, synchronous tasks and asynchronous tasks

Synchronous tasks are executed on the main thread, forming an execution stack; asynchrony is achieved through callback functions.

There are three common types of asynchronous tasks:

Ordinary events: such as click, resize, etc.

Resource loading, such as load, error, etc.

Timer, including setInterval, setTimeout, etc.

First execute the synchronous tasks in the execution stack, and put the asynchronous tasks into the task queue. Once the synchronous tasks in the execution stack are completed, the system will read the asynchronous tasks in the task queue in order, so the read asynchronous task ends the waiting state and enters the execution stack.

What are the characteristics of JavaScript? 1. Js belongs to an explanatory scripting language. 2. With the support of most browsers, js can run on multiple platforms and has cross-platform characteristics. 3. Js is a weakly typed scripting language that does not make strict requirements on the data types used. It is able to type conversion, simple and easy to use. 4. Js language is highly secure, and it can only browse information or interact dynamically through the browser, so as to effectively prevent the loss of data. 5, object-based scripting language, js can not only create objects, but also use existing objects.

The above is all the content of this article "what does javascript synchronization mean?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.

Share To

Development

Wechat

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

12
Report