What is the this Keyword in JavaScript?

What is the this Keyword in JavaScript?

Ferenc Almasi • 2020 November 12 • Read time 1 min read
  • twitter
  • facebook
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.

The global object in the browser

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 callthis will refer to the context passed in as the first parameter.

What is the this Keyword in JavaScript?
If you would like to see more Webtips, follow @flowforfrank

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.

What Is “this”, After All? — A Look at JavaScript this Keyword
  • twitter
  • facebook
JavaScript
Did you find this page helpful?
📚 More Webtips
Frontend Course Dashboard
Master the Art of Frontend
  • check Access 100+ interactive lessons
  • check Unlimited access to hundreds of tutorials
  • check Prepare for technical interviews
Become a Pro

Courses

Recommended

This site uses cookies We use cookies to understand visitors and create a better experience for you. By clicking on "Accept", you accept its use. To find out more, please see our privacy policy.