본문 바로가기

ES6

Renaming

반응형

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를 이용해서 디스트럭처링 할 수 있다.

반응형

'ES6' 카테고리의 다른 글

Array Destructuring  (0) 2020.09.18
Object Destructuring  (0) 2020.09.18
Array.findIndex(), Array.fill()  (0) 2020.09.18
Array.from() - 매우 중요  (0) 2020.09.18
string 메소드 - includes(), repeat(), startsWith(), endsWith()  (0) 2020.09.18