ES15
版本信息
版本介绍
ECMAScript 2024
, the 15th edition, added facilities for resizing and transferring ArrayBuffers and SharedArrayBuffers
; added a new RegExp /v flag for creating RegExps
with more advanced features for working with sets of strings; and introduced the Promise.withResolvers
convenience method for constructing Promises, the Object.groupBy
and Map.groupBy
methods for aggregating data, the Atomics.waitAsync
method for asynchronously waiting for a change to shared memory, and the String.prototype.isWellFormed
and String.prototype.toWellFormed
methods for checking and ensuring that strings contain only well-formed Unicode.
版本概要
- Well-Formed Unicode Strings
- Atomics.waitAsync
- RegExp v flag with set notation + properties of strings
- Resizable and growable ArrayBuffers
- Array Grouping
- Promise.withResolvers
- ArrayBuffer transfer
版本特性
Well-Formed Unicode Strings
分组
- Object.groupBy()
- Array.prototype.group()
- Map.groupBy()
js
const array = [1, 2, 3, 4, 5]
// `Object.groupBy` groups items by arbitrary key.
// In this case, we're grouping by even/odd keys
Object.groupBy(array, (num, index) => {
return num % 2 === 0 ? 'even' : 'odd'
})
// => { odd: [1, 3, 5], even: [2, 4] }
// `Map.groupBy` returns items in a Map, and is useful for grouping
// using an object key.
const odd = { odd: true }
const even = { even: true }
Map.groupBy(array, (num, index) => {
return num % 2 === 0 ? even : odd
})
// => Map { {odd: true}: [1, 3, 5], {even: true}: [2, 4] }
正则v
修饰符
TODO: 待补充
Promise.withResolvers
TODO: 待补充
Atomics.waitAsync
TODO: 待补充
ArrayBuffer.prototype.transfer
TODO: 待补充