≪ Today I learned. RSS購読
公開日
更新日
タグ
JavaScript
著者
ダーシノ(@bc_rikko)

ES2024のリリース候補

ES2024に追加される新機能が決まった。

ArrayBuffer関連

正規表現 vフラグ

Promise#withResolvers

// Before: resolve/rejectを取り出す
let resolve, reject;
const promise = new Promise((res, rej) => {
  resolve = res;
  reject = rej;
});

// After
const {promise, resolve, reject} = Promise.withResolvers();

Object#groupBy、Array#groupBy

const nums = [1, 2, 3, 4, 5];

// Before
const reduce = nums.reduce((ret, num) => {
  if (num % 2 === 0) {
    ret.even.push(num);
  } else {
    ret.odd.push(num);
  }
  return ret;
}, { odd: [], even: []})

// After
const groupBy = Object.groupBy(nums, (num, _index) => {
  return num % 2 === 0 ? 'even': 'odd';
});

Atomics#waitAsync

String#isWellFormed、String#toWellFormed


追記: 2024-06-23