Skip to content

内置对象速览 ​

全局环境内置了现代 JS 的常用对象,无需 import:

类别对象
基础Object Array String Number Boolean Symbol BigInt Math JSON RegExp
集合Map Set WeakMap WeakSet
元编程Proxy Reflect Iterator
异步Promise
二进制ArrayBuffer DataView 与 TypedArray 家族
弱引用WeakRef FinalizationRegistry
错误完整错误类型族(TypeError / RangeError / SyntaxError / ReferenceError …)
日期时间Temporal —— 取代 Date 的现代日期时间 API
js
console.log([1, 2, 3].filter(v => v > 1).reduce((a, b) => a + b))  // → 5
console.log(Math.hypot(3, 4))                                       // → 5
console.log(JSON.stringify({ ok: true }, null, 2))

let m = new Map([["a", 1]])
m.set("b", 2)
console.log([...m.keys()])                                          // → [a, b]

完整清单(含每个对象的可用方法)见 API 参考 §3。

Apache License 2.0 · 用 ❤ 和 Go 编写