Facebook Pixel
The this Keyword in JavaScript: A Complete Guide

What are the five this binding rules in JavaScript?

The answer

Default binding (plain call), implicit binding (method call), explicit binding (call/apply/bind), new binding (constructor), and lexical binding (arrow functions inherit from enclosing scope).

More FAQs in The this Keyword in JavaScript: A Complete Guide

By how the function is called, not where it is defined (except for arrow functions). Plain call: global or undefined (strict). Method call: the object. call/apply/bind: explicit. new: new object. Arrow: lexical (inherited from enclosing scope).

new binding (highest) > explicit binding (bind/call/apply) > implicit binding (method call) > default binding (plain call). Arrow functions are an exception: they use lexical this and ignore all of these rules.

Arrow functions do not have their own this. They inherit this from their enclosing lexical scope at definition time. call, apply, and bind cannot change an arrow's this. This is why arrows fix the this-in-callback bug.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Your learning library

Small steps. Big possibilities.

Find your next course. Build something great.

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.