[ECMAScript] ES2019

빛트·2022년 7월 14일
0

ECMASCRIPT

목록 보기
6/8
post-thumbnail

Object.fromEntries()

let entries = [['key1','val1'],['key2':'val2']];
Object.fromEntries(entries); // {key1: 'val1', key2: 'val2'}

String trim

let str = '    str    ';
str.trimStart(); 
str.trimLeft(); 
str.trimEnd(); 
str.trimRight(); 

Array.prototype.flat

let arr = [[1,2,[3,4,[5]]],[6,7]];
arr.flat(); // [1,2,[3,4,[5]],6,7]
arr.flat(Infinity); // [1,2,3,4,5,6,7]

Array.prototype.flatMap

let arr = ['123','456'];
arr.flatMap((v) => v.split('')); // ['1','2','3','4','5','6']
profile
https://kangbit.github.io/posts

0개의 댓글