// 문자열 변수

var str = 'hello';


// 오브젝트 변수

var obj = { first: 'world' };


// function 변수

var func = () => { ... };


// function

function func() { ... }


// closure

(() => { alert('closure1'); })();



var closure2 = (() => (

{

three: () => (3),

alert: (n) => {

alert(n)

}

}

))();


closure2.three() // 3

closure2.alert(5)


<Closure 사용 이유?>

함수를 사용한 후 메모리에 남아있지 않게 한다


'Language' 카테고리의 다른 글

[Node.js] npm install option  (0) 2018.01.06
[Javascript] ESLint? / 설치  (0) 2018.01.05
[Language] Node.js? Webpack? Javascript? CommonJS?  (0) 2018.01.05
[Language] Webpack이란?  (0) 2018.01.04
[Language] Node.js와 CommonJS  (0) 2018.01.04

WRITTEN BY
hojongs
블로그 옮겼습니다 https://hojongs.github.io/