Slide 10
Slide 10 text
ΦϒδΣΫτͷॳظԽͱׂೖ
w TIPSUIBOEQSPQFSUJFT
w ͕ϓϩύςΟ໊ͱಉ͡ม໊ͷͱ͖
ͷ෦ΛলུͰ͖Δ
w DPNQVUFEQSPQFSUJFT
w ϓϩύςΟ໊ΛมͰࢦఆ͢Δ
w ׂೖʢEFTUSVDUVSJOHBTTJHONFOUʣ
w ྻΦϒδΣΫτ͔ΒҰ෦ͷΛऔΔ
w SFTUQBSBNFUFST
w ׂೖͰ༻ͨ͠Ҏ֎ͷ෦Λड͚औΔ
1 // shorthand properties
2 const id = 11
3 const name = 'Dr Nice'
4 const hero = { id, name }
5 console.log(hero.id) // > 11
6 console.log(hero.name) // > Dr Nice
7
8 // computed properties
9 const propertyName = 'text'
10 const todo = { [propertyName]: 'Learn JavaScript' }
11 console.log(todo.text) // > Learn JavaScript
12
13 // ׂೖ
14 const session = { room: 'B5', speaker: '@likr', start: '11:00' }
15 const { room, speaker } = session
16 console.log(room, speaker) // > B5 @likr
17 const { start: startTime } = session
18 console.log(startTime) // > 11:00
19
20 const primes = [2, 3, 5, 7]
21 const [p1, p2] = primes
22 console.log(p1, p2) // > p1 p2
23
24 // rest parameters
25 const [head, ...tail] = primes
26 console.log(head) // > 2
27 console.log(tail) // > [ 3, 5, 7 ]
28
29 const session2 = { room: 'B5', speaker: '@okunokentaro', start: '11:45' }
30 const { speaker: speaker2, ...rest } = session2
31 console.log(rest.room) // > B5
32 console.log(rest.speaker) // > undefined
IUUQTEFWFMPQFSNP[JMMBPSHEPDT8FC+BWB4DSJQU3FGFSFODF0QFSBUPST%FTUSVDUVSJOH@BTTJHONFOU
IUUQTEFWFMPQFSNP[JMMBPSHEPDT8FC+BWB4DSJQU3FGFSFODF0QFSBUPST0CKFDU@JOJUJBMJ[FS