[ECMAScript] ES2017

빛트·2022년 7월 14일
0

ECMASCRIPT

목록 보기
4/8
post-thumbnail

async / await

const foo = async () => {
  let result = await Promise.resolve(true);
  return result;
};

Object.values()

const obj = {
  key1: "value1",
  key2: "value2",
}
let values = Object.values(obj); 
console.log(values); // [ 'value1', 'value2' ]

Object.entries()

const obj = {
  key1: "value1",
  key2: "value2",
}
let entries = Object.entries(obj); 
console.log(entries); // [ [ 'key1', 'value1' ], [ 'key2', 'value2' ] ]

String Padding

let str = "hi";
str = str.padStart(3); // " hi"
str = str.padStart(5, "*"); // "** hi"
let str = "hi";
str = str.padEnd(5); // "hi   "
str = str.padEnd(8, "*"); // "hi   ***"

Trailing commas in function parameter lists and calls

foo(
  a,
  b, // 마지막에 comma 삽입 가능
)

Object.getOwnPropertyDescriptors()

const description = Object.getOwnPropertyDescriptors(obj);

0개의 댓글