Promise实现为什么是用JS 而不是用引擎

"

Bluebird author here.

V8 promises implementation is written in JavaScript not C. All JavaScript (including V8's own) is compiled to native code.

Additionally user written JavaScript is optimized, if possible (and worth it), before compiled to native code.

Promises implementation is something that would not benefit much or at all from being written in C, in fact it would only make it slower because all you are doing is manipulating JavaScript objects and communication.

"

因为promise的操作都是在操纵js对象,控制他们通信,使用js效率更高

posted @ 2020-05-15 21:52  eret9616  阅读(59)  评论(0编辑  收藏