본문 바로가기

javaScripts

12/26

this에 관하여 :

1. Global: window

2. Function 호출: window

3. Method 호출: 부모 object

  ex) 

let obj = {

   value: 0,

   counter: {

      value: 0,

      increment: function() {

         this.value++;

      }

   }

}

     => 여기서 this는 counter 

4. Construction mode (new 연산자로 생성된 function  영역의 this: 새로 생성된 객체

5. .call or .apply 호출: call, apply의 첫번째 인자로 명시된 객체

'javaScripts' 카테고리의 다른 글

Inheritance Patterns  (0) 2020.01.11
__proto__, constructor, prototype 의 관계  (0) 2020.01.03
About Object  (0) 2019.12.27
12/25  (0) 2019.12.25