基于安全考虑,小程序中不支持动态执行 JS 代码,即:
- 不支持使用 eval执行 JS 代码
- 不支持使用 new Function创建函数
微信小程序已经支持了绝大部分的 ES6 API,已支持的 API 如下(部分 API 依赖系统版本):
| String | iOS10+ | Android | 
|---|
| codePointAt |  |  | 
| normalize |  |  | 
| includes |  |  | 
| startsWith |  |  | 
| endsWith |  |  | 
| repeat |  |  | 
| String.fromCodePoint |  |  | 
| Array | iOS10+ | Android | 
|---|
| copyWithin |  |  | 
| find |  |  | 
| findIndex |  |  | 
| fill |  |  | 
| entries |  |  | 
| keys |  |  | 
| values |  | ✘ | 
| includes |  |  | 
| Array.from |  |  | 
| Array.of |  |  | 
| Number | iOS10+ | Android | 
|---|
| isFinite |  |  | 
| isNaN |  |  | 
| parseInt |  |  | 
| parseFloat |  |  | 
| isInteger |  |  | 
| EPSILON |  |  | 
| isSafeInteger |  |  | 
| Math | iOS10+ | Android | 
| trunc |  |  | 
| sign |  |  | 
| cbrt |  |  | 
| clz32 |  |  | 
| imul |  |  | 
| fround |  |  | 
| hypot |  |  | 
| expm1 |  |  | 
| log1p |  |  | 
| log10 |  |  | 
| log2 |  |  | 
| sinh |  |  | 
| cosh |  |  | 
| tanh |  |  | 
| asinh |  |  | 
| acosh |  |  | 
| atanh |  |  | 
| Object | iOS10+ | Android | 
|---|
| is |  |  | 
| assign |  |  | 
| getOwnPropertyDescriptor |  |  | 
| keys |  |  | 
| getOwnPropertyNames |  |  | 
| getOwnPropertySymbols |  |  | 
| Other | iOS10+ | Android | 
|---|
| Symbol |  |  | 
| Set |  |  | 
| Map |  |  | 
| Proxy |  | ✘ | 
| Reflect |  |  | 
| Promise |  |  |