Notice
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 클로저
- jest
- NPM
- #cloudfront #s3 #html 확장자 없애기
- git pair
- TypeScript
- ESLint
- 기후변화
- url #querystring
- lightsail nodejs apache
- OOP
- this
- 객체참조 #객체
Archives
- Today
- Total
목록클로저 (1)
Hello World...
클로저 객체 메소드
클로저란, 내부함수가 리턴되어도 외부함수의 변수를 참조할 수 있는 것을 말하는데, 객체가 리턴되어도 객체의 메소드도 외부함수의 변수를 참조할 수 있다. const L = function() { const s = []; const obj = {}; obj.push = function(v) { s.push(v); }; obj.get = function() { return s; }; return obj; }; const tl = L(); console.log(tl); tl.push(1); tl.push(2); console.log(tl.get()); // console // { push: [Function], get: [Function] } // [ 1, 2 ] obj 가 리턴되어도 obj 의 메소드를 이용해..
javascript
2020. 1. 1. 17:46