Skip to content

Latest commit

 

History

History
109 lines (87 loc) · 9.48 KB

File metadata and controls

109 lines (87 loc) · 9.48 KB
id javascript-environment
title JavaScript Environment

import TableRow from '@site/core/TableRowWithCodeBlock';

JavaScript Runtime

When using React Native, you're going to be running your JavaScript code in up to three environments:

  • In most cases, React Native will use Hermes, an open-source JavaScript engine optimized for React Native.
  • If Hermes is disabled, React Native will use JavaScriptCore, the JavaScript engine that powers Safari. Note that on iOS, JavaScriptCore does not use JIT due to the absence of writable executable memory in iOS apps.
  • When using Chrome debugging, all JavaScript code runs within Chrome itself, communicating with native code via WebSockets. Chrome uses V8 as its JavaScript engine.

While these environments are very similar, you may end up hitting some inconsistencies. It is best to avoid relying on specifics of any runtime.

JavaScript Syntax Transformers

Syntax transformers make writing code more enjoyable by allowing you to use new JavaScript syntax without having to wait for support on all interpreters.

React Native ships with the Babel JavaScript compiler. Check Babel documentation on its supported transformations for more details.

A full list of React Native's enabled transformations can be found in @react-native/babel-preset.

https://babeljs.io/docs/learn-es2015/#arrows" /> https://babeljs.io/docs/learn-es2015/#classes" /> https://babeljs.io/docs/en/babel-plugin-transform-function-name" /> https://react.dev/learn/writing-markup-with-jsx" />
TransformationCode
ECMAScript 5
ECMAScript 2015 (ES6)
ECMAScript 2016 (ES7)
ECMAScript 2017 (ES8)
ECMAScript 2018 (ES9)
ECMAScript 2019 (ES10)
ECMAScript 2020 (ES11)
ECMAScript 2022 (ES13)
Stage 1 Proposal
Miscellaneous

Polyfills

Many standard functions are also available on all the supported JavaScript runtimes.

Browser

ECMAScript 2015 (ES6)

  • Array.from
  • md Array.prototype.{[find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find), [findIndex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)}
  • Object.assign
  • md String.prototype.{[startsWith](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith), [endsWith](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith), [repeat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat), [includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)}

ECMAScript 2016 (ES7)

  • md Array.prototype.[includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)

ECMAScript 2017 (ES8)

  • md Object.{[entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries), [values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values)}

Specific

  • __DEV__