본문 바로가기
TIL/Node JS

비구조화 할당 (destructuring)

by koreashowme 2019. 10. 19.

const a = 객체.a;

const b = 객체.b;

// 다음과 같이 바꿀 수 있다.

const { a, b } = 객체 ;

 

const { status, getCandy } = candyMachine;

 

candyMachine라는 객체에서, status랑 getCandy를 변수로 꺼내옴.

 

 

const { Router } = require('express');

// require('express')객체에서, Router라는 변수로 꺼내옴

 

const array = ['node', {}, 10, true];

const [node, obj, , bool] = array;

 

//const [node, obj, ...bool] = array;

'TIL > Node JS' 카테고리의 다른 글

global, console.dir, console.log, console.trace()  (0) 2019.10.20
module.exports, 비구조화 할당  (0) 2019.10.20
const 바뀐점.  (0) 2019.10.19
콜백 함수(테스크 큐) QNA & 멀티 프로세싱  (0) 2019.10.19
None Blocking & IO  (0) 2019.10.19

comment