Masterbook/Chapter 13• 1 min read
View Raw Code on GitHub

Difference between implicit, explicit, default, and new binding

Difference between implicit, explicit, default, and new binding

JavaScript resolves "this" using four main rules. Default binding applies when a function is called without a receiver object. In non-strict mode, this becomes the global object; in strict mode, this is undefined. Implicit binding applies when you call a function as a property of an object; the object to the left of the dot becomes this. Explicit binding uses call, apply, or bind to set this to a specific object regardless of how the function is invoked. New binding applies when you use new; it creates a fresh object, sets it as this inside the constructor, and returns it unless the constructor returns an object explicitly.