ES6
Renaming
liufeier
2020. 9. 18. 21:46
반응형
See the Pen 200918-15 by hwd3004 (@hwd3004) on CodePen.
api로부터 데이터를 받아왔다고 가정하고, 받아온 데이터의 이름이 chosen_color인데,
이걸 chosenColor로 하고 싶어서 Renaming을 한다.
See the Pen 200918-16 by hwd3004 (@hwd3004) on CodePen.
디스트럭처링 한 코드.
See the Pen 200918-17 by hwd3004 (@hwd3004) on CodePen.
({color: {chosen_color: chosenColor = 'light'}} = settings)
새 변수를 생성하는 대신에 let 변수인 chosenColor를 업데이트함.
데이터를 업데이트해야된다면 let를 이용해서 디스트럭처링 할 수 있다.
반응형