简体   繁体   中英

The benefits of React-Native JavaScriptCore

Definitely, all of us know about powerful JavaScript engine, So why in React Native is used a different engine that name is JavaScriptCore .

The JavaScriptCore does not support some ES6 features like below function:

Array.prototype.flatten

What is benefits of JavaScriptCore to V8? Why the Facebook developers didn't use V8?

V8 does not run on iOS, because Apple does not allow third-party apps to generate code at runtime (aka "JIT-compiling"), which V8 heavily relies on for performance (*). JavaScriptCore, being made by Apple, is allowed to run (and JIT-compile code) on iOS. Since React Native's purpose is cross-platform development, this is a strong argument.

That said, Array.prototype.flatten is not an ES6 feature. It is currently a " stage 3 proposal ", meaning it will probably soon become an official part of JavaScript -- maybe ES2019 ("ES10" in the old naming scheme) or so. Also, it has been renamed to Array.prototype.flat due to web compatibility issues with the name .flatten . JavaScript engines have started to implement it; according to MDN the latest version of Safari/JavaScriptCore already support it, so it's probably only a matter of time until support arrives in React Native too.

(*) There is an ongoing effort to build a version of V8 that avoids all runtime code generation, trading a lot of performance for the ability to run anywhere, but it's not available yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM