Skip to content
Discussion options

You must be logged in to vote

this의 값은 호출하는 방법에 따라 달라집니다.

  • 일반적인 함수 호출에서 this 는 전역 객체를 가리킵니다. 하지만 strict mode에서는 전역 객체를 가리키지 않고 undefined가 됩니다.
  • 객체의 메서드로 함수가 호출되면 this는 해당 메서드를 호출한 객체를 가리킵니다.
  • 생성자 함수로 객체를 생성할 때 this 는 새로 생성된 객체(인스턴스)를 가리킵니다.
  • call(), apply(), bind() 를 사용하여 명시적으로 this 를 바인딩할 수 있습니다.
  • 화살표 함수에서 this는 함수가 생성될 때의 상위 스코프의 this를 참조합니다.

Replies: 1 comment

Comment options

hsmurf
Mar 29, 2024
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by hsmurf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
1 participant