본문 바로가기

Hello World...

검색하기
Hello World...
프로필사진 FaustK

  • 분류 전체보기 (91)
    • flutter (5)
    • javascript (15)
    • typescript (3)
    • node.js (8)
    • vue.js (8)
    • react.js (8)
    • nest.js (4)
    • aws (2)
    • git (2)
    • algorithm (2)
    • programming (8)
    • ChatGPT (6)
Guestbook
Notice
«   2025/05   »
일 월 화 수 목 금 토
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
  • 객체참조 #객체
more
Archives
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록클로저 (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
Prev 1 Next

Blog is powered by kakao / Designed by Tistory

티스토리툴바