What is (this) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is (this)

keyword in javascript called this but it is so hard to understand the mean of the

25th May 2023, 5:45 PM
Farhad Rahmani
Farhad Rahmani - avatar
1 Answer
+ 5
It is a special keyword that allows you to access properties and methods of the object that invoked the function. When this is used in the global scope (outside of any function), it refers to the global object, which is typically window in a browser or global in Node.js. When this is used within a method of an object, it refers to the object itself. When a function is used as a constructor function with the new keyword, this refers to the newly created object instance. https://www.w3schools.com/js/js_this.asp this is where you can understand it in a lil more n extended way
25th May 2023, 5:55 PM
I am offline
I am offline - avatar