Slide 44
Slide 44 text
Spread Syntax
• ... を使うと配列やオブジェクトを展開出来る
const sum = (a, b, c, d) => a + b + c + d
const nums = [1, 2]
const copied = [...nums] // தΛෳͨ͠ྻΛ࡞ΕΔ
const moreNums = [...copied, 5] // [1, 2, 5]
sum(...nums, 10) // 18
const obj = { a: 10, b: "foo" }
const obj2 = { b: "bar", c: true }
// 2ͭҎ্ͷobjectΛmerge͢ΔɻΩʔ͕ॏෳ͍ͯ͠Δ߹ޙʹॻ͍ͨํͰ্ॻ͖͞ΕΔ
const merged = { ...obj, ...obj2 } // {a: 10, b: 'bar', c: true}
const getUserConfig = (received) => ({
force: false,
allowJs: false,
...received, // σϑΥϧτΛ͞Ε͕ͨ͋Ε্ॻ͖͢Δ
})
#hatenaintern)*)+