tencent cloud

Tencent Cloud Super App as a Service

JavaScript Support Overview

Download
Focus Mode
Font Size
Last updated: 2025-07-04 16:48:09

Execution restrictions

For security reasons, mini programs do not support the dynamic execution of JavaScript code, which means:
Using eval to execute JavaScript code is not allowed.
Creating functions with new Function is not permitted.

Standard ECMAScript support

The JavaScript execution environment for mini programs varies across different platforms, leading to differences in support for the ECMAScript standard.
To minimize these discrepancies, the mini program's core library includes a native core-js Polyfill core-js polyfill.Core-js can fill in the standard APIs that may be missing in certain platform environments.
However, it is important to note that differences in platform support for ECMAScript syntax cannot be completely bridged. When you need to use advanced syntax, such as async/await , you will need to enable the feature to transpile ES6 to ES5 to support these syntaxes.

APIs not supported by Polyfill

The following APIs cannot be used in some older versions of the client, so it is advisable to avoid using them:Proxy objects.

Differences from the standards

Promise execution order differences

Due to limitations in iOS JavaScriptCore, in iOS 15 and earlier, Promise are implemented using a setTimeout-based polyfill. This means that tasks triggered by Promise are treated as regular tasks rather than microtasks, resulting in differences in Promise execution order compared to the standard.
There are no such differences in iOS 16 and later.
var arr = []

setTimeout(() => arr.push(6), 0)
arr.push(1)
const p = new Promise(resolve => {
arr.push(2)
resolve()
})
arr.push(3)
p.then(() => arr.push(5))
arr.push(4)
setTimeout(() => arr.push(7), 0)

setTimeout(() => {
// Expected output: [1, 2, 3, 4, 5, 6, 7]
// In the iOS 15 mini program environment, this will output: [1,2,3,4,6,5,7]
console.log(arr)
}, 1000)
For more information on the differences between regular tasks and microtasks, you can refer to In depth: Microtasks and the JavaScript runtime environment.



Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback