DEV Community

Discussion on: Is "this" really that complicated in JavaScript?

Collapse
 
bendman profile image
Ben Duncan • Edited

To summarize: unless someone changes it using call/apply/bind or you are inside of an arrow function, this refers to whatever is left of the last dot at the point of invocation.

button.click(); // this === button
whatIsThis(); // this === undefined (or the global/window object in non-strict context, because whatIsThis === window.whatIsThis)
newPhone.useApps() // this === newPhone
Enter fullscreen mode Exit fullscreen mode