Magazine Logo
๐Ÿ“Œ Press Ctrl+D to bookmark this page.

JavaScript Objects

What is (this)?

In JavaScript, the this keyword refers to an object.

Which object depends on how this is being invoked (used or called).

The this keyword refers to different objects depending on how it is used:

In an object method, this refers to the object.
Alone, this refers to the global object.
In a function, this refers to the global object.
In a function, in strict mode, this is undefined.
In an event, this refers to the element that received the event.
Methods like call(), apply(), and bind() can refer this to any object.

Sample1: Object


Sample2: Object


Sample3: this


Sample4: this


Sample5: Compress


Leave a Comment

Your email address will not be published. Required fields are marked *

AdsReg Magazine We would like to show you notifications for the latest news and updates. You can disable it when you want.
Allow Notifications