JavaScript. Dom

[meɪ]·2021년 9월 5일
0

새로 추가된 DOM

  • String.replaceAll() : 모든 문자열을 대체함
// 🎵 모든 'l'을 '~'로 바꾸지
const str = "Hello World"
console.log(str.replace(/l/g, "~"));
// ↓
console.log(str.replaceAll("l", "~"));
// ⬇️ Output
// He~~o Wor~d
  • Promise.any : Promise.race는 promise 중 가장 먼저 완료된 결과 값으로 이행/거부하는 반면, Promise.any는 promise 중 가장 먼저 이행된 객체 반환

  • Logical Assignment Operators

// 🎵 논리할당연산자 줄여쓰기
num1 = num1 || 0;
num2 ||= 0; // 'num2 = num2 || 0'을 바꿔서 쓴 것
// ↓ 이렇게 쓸 수도 있음
num1 ||= 0;
num2 ||= 0;
name = name && `Hello ${name}`;
// ↓ 
name &&= `Hello ${name}`;
  • Numeric Seperators
    under bar로 숫자 구분자를 사용할 수 있음
let billion = 1_000_000_000
billion // 100000000
  • WeakRef
    MDN에서 사용을 자제하라고 한 만큼 신중히 사용할 것
    특정 객체를 일정 시간만 cache하도록 만들 수 있음

Endnote

🙇 the source of this content

코딩앙마

profile
느려도 할 거야.......

0개의 댓글