콘텐츠로 이동
Search

JavaScript:Rest/Spread

Dictionary 병합/분해시 사용하는 ... 문법. (e.g. let food = {...a,...b})

Rest

let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
x; // 1
y; // 2
z; // { a: 3, b: 4 }

Spread

Using ES6 Spread operator

let a = {};
a['fruit'] = "apple";

let b = {};
b['vegetable'] = "carrot";

let food = {...a,...b}

console.log(food)

See also

Favorite site

lastmod 2021-07-15created 2021-07-15author Zer0 sitemap