React-Native JavaScriptCore 的好处
The benefits of React-Native JavaScriptCore
当然,我们都知道强大的 JavaScript
引擎,那么为什么在 React Native
中使用另一个名为 JavaScriptCore
的引擎。
JavaScriptCore 不支持某些 ES6
功能,例如以下功能:
Array.prototype.flatten
JavaScriptCore 对 V8 有什么好处?为什么 Facebook 开发人员不使用 V8?
V8 不会在 iOS 上 运行,因为 Apple 不允许第三方应用程序在 运行 时间生成代码(a.k.a。"JIT-compiling"),V8 严重依赖它来提高性能 (*)。 Apple 开发的 JavaScriptCore 允许在 iOS 上 运行(和 JIT 编译代码)。由于 React Native 的目的是跨平台开发,这是一个强有力的论据。
也就是说,Array.prototype.flatten
不是 ES6 的特性。它目前是“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 Safari/JavaScriptCore 的最新版本已经支持它,所以 React Native 也支持它可能只是时间问题。
(*) 有一个 ongoing effort 可以构建一个避免所有 运行 时间代码生成的 V8 版本,以大量性能换取 运行 任何地方的能力,但还没有。
当然,我们都知道强大的 JavaScript
引擎,那么为什么在 React Native
中使用另一个名为 JavaScriptCore
的引擎。
JavaScriptCore 不支持某些 ES6
功能,例如以下功能:
Array.prototype.flatten
JavaScriptCore 对 V8 有什么好处?为什么 Facebook 开发人员不使用 V8?
V8 不会在 iOS 上 运行,因为 Apple 不允许第三方应用程序在 运行 时间生成代码(a.k.a。"JIT-compiling"),V8 严重依赖它来提高性能 (*)。 Apple 开发的 JavaScriptCore 允许在 iOS 上 运行(和 JIT 编译代码)。由于 React Native 的目的是跨平台开发,这是一个强有力的论据。
也就是说,Array.prototype.flatten
不是 ES6 的特性。它目前是“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 Safari/JavaScriptCore 的最新版本已经支持它,所以 React Native 也支持它可能只是时间问题。
(*) 有一个 ongoing effort 可以构建一个避免所有 运行 时间代码生成的 V8 版本,以大量性能换取 运行 任何地方的能力,但还没有。