AdsReg.com 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

JavaScript/009-Objects/001

Sample2: Object

JavaScript/009-Objects/002

Sample3: this

JavaScript/009-Objects/003-this

Sample4: this

JavaScript/009-Objects/004-this

Sample5: Compress

JavaScript/009-Objects/005-this-ZIP

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.
Dismiss
Allow Notifications