TIL 2020.12.01

arrow function, this, binding pattern

arrow function


  • determined by how a function is called (invocation)
  • can’t be set by assignment during execution, and it may be different each time the function is called
  • 호출할 때, 결정 된 객체(누가 호출했는지)

5 function invocation

  1. Global

2. function invocation

3. method invocation

4. constructor invocation with new keyword

  • 생성자 호출을 할 경우, this는 new 키워드로 생성한 Counter의 인스턴스

5. invocation of .call or .apply

  • use when you want to assign ‘this’ explicitly
  • first argument is always value for ‘this’
  • this뒤에는 다 매개변수로 사용됨
  • 인자가 많으면 Product.apply(this, arguments) 가 더 유용합니다.
.call(this, a, b, c)
.apply(this, [a, b, c])

bind method

  • similar to call method
  • a function that return a function that is bind, not binding or operating ‘this’ and arguments
  • first argument is ‘this’
  • deliver necessary parameter from second arguments
  • 영구적으로 묶여지고 실행하지는 않지만 묶은 함수를 반환

binding pattern

Consistency achieves everything https://github.com/paigekim29