Skip to content

ES15

版本信息

版本介绍

来源: https://tc39.es/ecma262/2024/#sec-intro

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

分组

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: 待补充