What is the this Keyword in JavaScript?
The “this
” keyword in JavaScript refers to the object it belongs to. By default in the browser, it refers to the global object which is the window
.
Keep in mind that if it is used inside an arrow function, it refers to the enclosing scope as arrow functions don’t bind their own context. Also, note that if a function is called with bind
or call
, this
will refer to the context passed in as the first parameter.
If you are interested in reading more about the this
keyword, or you would like to see some practical examples, make sure to check out the article below.
📚 More Webtips
Master the Art of Frontend
- Access 100+ interactive lessons
- Unlimited access to hundreds of tutorials
- Prepare for technical interviews