[ECMAScript] ES2018

빛트·2022년 7월 14일
0

ECMASCRIPT

목록 보기
5/8
post-thumbnail

Object Rest/Spread

let obj = {
  key1: 'value1',
  key2: 'value2',
}
let obj2 = { ...obj, key3: 'value3'};

Promise finally

const promise = new Promise((resolve, reject) => {});
promise
  .then(()=>{})
  .finally(()=>{});

Async iteration

const foo = async () => {
  let time = 1000;
  const promises = ["a", "b", "c"].map((str) => {
    return new Promise((res, rej) => {
      setTimeout(() => res(str), (time += 1000));
    });
  });

  for await (const result of promises) {
    console.log(result);
  }
};
profile
https://kangbit.github.io/posts

0개의 댓글