简体   繁体   English

React-Native JavaScriptCore的好处

[英]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 . 当然,我们所有人都知道强大的JavaScript引擎,那么为什么在React Native中使用了一个名为JavaScriptCore的不同引擎。

The JavaScriptCore does not support some ES6 features like below function: JavaScriptCore不支持以下功能的一些ES6功能:

Array.prototype.flatten

What is benefits of JavaScriptCore to V8? JavaScriptCore对V8有什么好处? Why the Facebook developers didn't use V8? 为什么Facebook开发者不使用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 (*). V8不能在iOS上运行,因为Apple不允许第三方应用程序在运行时生成代码(又名“JIT编译”),V8在很大程度上依赖于性能(*)。 JavaScriptCore, being made by Apple, is allowed to run (and JIT-compile code) on iOS. 由Apple制作的JavaScriptCore允许在iOS上运行(和JIT编译代码)。 Since React Native's purpose is cross-platform development, this is a strong argument. 由于React Native的目的是跨平台开发,这是一个强有力的论据。

That said, Array.prototype.flatten is not an ES6 feature. 也就是说, Array.prototype.flatten不是ES6功能。 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. 它目前是一个“ 第3阶段提案 ”,这意味着它可能很快将成为JavaScript的官方部分 - 也许是ES2019(旧命名方案中的“ES10”)左右。 Also, it has been renamed to Array.prototype.flat due to web compatibility issues with the name .flatten . 此外,由于与.flatten名称的Web兼容性问题,它已重命名为Array.prototype.flat JavaScript engines have started to implement it; JavaScript引擎已经开始实现它; 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. 根据MDN的说法,最新版本的Safari / JavaScriptCore已经支持它了,所以在支持到达React Native之前,这可能只是时间问题。

(*) 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. (*) 正在不断努力构建V8版本,避免所有运行时代码生成,为在任何地方运行的能力交换大量性能,但它尚不可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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