ES2026(第17版)
ECMAScript2026 已于2025年12月02日正式发布。
- GitHub ECMA-262 页面上已完成的 4 个提案获得了批准
Iterator Sequencing (迭代器排序)
Uint8Array to/from Base64(Uint8Array 的 base64编码)
基本用法
const arr = new Uint8Array([
72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100,
]);
console.log(arr.toBase64());
// 'SGVsbG8gV29ybGQ='Math.sumPrecise(多值求和)
添加一个接受可迭代对象的 Math.sumPrecise 方法,该方法使用比简单求和更精确的算法返回可迭代对象中值的总和。
基本用法
let values = [1e20, 0.1, -1e20];
values.reduce((a, b) => a + b, 0); // 0
Math.sumPrecise(values); // 0.1