You Don't Know JS: Async & Performance(第一章, 异步:now & later)


Chapter 1: Asynchrony: Now & Later

在一门语言中,比如JavaScript, 最重要但仍然常常被误解的编程部分是如何在一个完整的时间周期表示和操作程序行为。

这是关于当你的程序正在部分运行,其他部分等待运行。--这之间的gap。

mind the gap!(比如在subway door and the platform)

异步编程就是这个核心: now and later parts of your program

在JS的发展初级, callback function足够用了。但是JS继续在scope和complexity方向成长,为了满足不断扩展的要求(作为第一类编程语言,它运行在浏览器,服务器,已经每个它们之间的设备),开发者需要更强大的并且合理的功能。

后几章我们会探索各种异步的JS技术。

但此时我们将不得不更深度地理解什么是异步asynchrony, 它如何在JS操作!


A Program in Chunks

Async Console


Event Loop


Parallel Threading

Run-to-Completion


Concurrency并发

an example of event, actions etc happening at the same time!

Noninteracting 不交互

Interaction

Cooperation


Jobs

s of ES6, there's a new concept layered on top of the event loop queue, called the "Job queue." 

The most likely exposure you'll have to it is with the asynchronous behavior of Promises (see Chapter 3).

So, the best way to think about this that I've found is that the "Job queue" is a queue hanging off the end of every tick in the event loop queue.


Statement Ordering


Review

猜你喜欢

转载自www.cnblogs.com/chentianwei/p/9764894.html