Mini Program Javascript Engine
Running Engine
Mini program JavaScript codes fall into logic layer script and sjs script, which run on different threads in the the same JavaScript engine. Mini Program JavaScript Engine is different on different OSs. On the iOS platform, the script runs on the JavaScriptCore provided by the operating system. On the Android platform, the script runs on the V8 engine .
Mini program performs the babel conversion for the codes uploaded by the developers, so that the JavaScript engine supports most of the ES6 new features. For the internal object of the ES6 extension, Mini Program does not provide polyfill on the JavaScript engine, which causes difference on the supports for different ES6 extension internal objects for the JavaScript on different platforms. the developers need to avoid using the internal objects unsupported by JavaScript engine, and can provide polyfill for the internal objects. (Polyfill means the unsupported raw API codes that are used to implement browsers or other JavaScript engines, such as babel-polyfill)
Supports of Client OSs for ES6 Extension Internal Objects
The table below lists the OS supports for ES6 extension internal objects.
Object | iOS 9 | iOS 10 and above | Android |
Object.is | Support | Support | Support |
Object.assign | Support | Support | Support |
Object.keys | Support | Support | Support |
Object.getOwnPropertyDescriptor | Support | Support | Support |
Object.getOwnPropertyNames | Support | Support | Support |
Object.getOwnPropertySymbols | Support | Support | Support |
String | iOS 9 | iOS 10 and above | Android |
String.prototype.codePointAt | Support | Support | Support |
String.prototype.normalize | No support | Support | Support |
String.prototype.includes | Support | Support | Support |
String.prototype.startsWith | Support | Support | Support |
String.prototype.endsWith | Support | Support | Support |
String.prototype.repeat | Support | Support | Support |
String.fromCodePoint | Support | Support | Support |
Array | iOS 9 | iOS 10 and above | Android |
Array.prototype.copyWithin | Support | Support | Support |
Array.prototype.find | Support | Support | Support |
Array.prototype.findIndex | Support | Support | Support |
Array.prototype.find | Support | Support | Support |
Array.prototype.entries | Support | Support | Support |
Array.prototype.keys | Support | Support | Support |
Array.prototype.values | Support | Support | No support |
Array.prototype.includes | Support | Support | Support |
Array.from | Support | Support | Support |
Array.of | Support | Support | Support |
Number | iOS 9 | iOS 10 and above | Android |
Number.isFinite | Support | Support | Support |
Number.isNaN | Support | Support | Support |
Number.parseInt | Support | Support | Support |
Number.parseFloat | Support | Support | Support |
Number.isInteger | Support | Support | Support |
Number.EPSILON | Support | Support | Support |
Number.isSafeInteger | Support | Support | Support |
Math | iOS 9 | iOS 10 and above | Android |
Math.trunc | Support | Support | Support |
Math.sign | Support | Support | Support |
Math.cbrt | Support | Support | Support |
Math.clz32 | Support | Support | Support |
Math.imul | Support | Support | Support |
Math.fround | Support | Support | Support |
Math.hypot | Support | Support | Support |
Math.expm1 | Support | Support | Support |
Math.log1p | Support | Support | Support |
Math.log10 | Support | Support | Support |
Math.log2 | Support | Support | Support |
Math.sinh | Support | Support | Support |
Math.cosh | Support | Support | Support |
Math.tanh | Support | Support | Support |
Math.asinh | Support | Support | Support |
Math.acosh | Support | Support | Support |
Math.atanh | Support | Support | Support |
Internal objects | iOS 9 | iOS 10 and above | Android |
Set | Support | Support | Support |
Map | Support | Support | Support |
Proxy | No support | Support | Support |
Reflect | Support | Support | Support |
Promise | Support | Support | Support |
Limitations on Dynamic Execution Script
For sake of security, Mini Program limits some of the syntax and APIs of ES.
- It does not support eval using
- setTimeout and setInterval functions, and supports only the function for callback parameters. Dynamic execution of codes is not supported.
- It does not support using new Function to create a function.
Reserved Words of Module Name
The logic layer of Mini Program supports the ES2015 module syntax but regards some internal object names (such as window and document) of browser as the reserved words for emergency needs in the future. Those reserved words cannot be used as the module name. The reserved words include globalThis
, global
, fetch
, self
, window
, document
, location
and XMLHttpRequest
. For more details, see the descriptions of module name reserved words in framework description.