this is javascript
//this refer to global object or window object //but when we call this inside method of object it refers to current object console.log(this===window)//true let user = { name: "Shirshak", age: 25, sayHi() { // "this" is the "current object" console.log(this.name); //print shirshak } };
this js
let user = { name: "John", age: 30, sayHi() { // "this" is the "current object" alert(this.name); } }; user.sayHi(); // John
Source: javascript.info
this keyword in javscript
const user = { name: 'Mike'; call() { console.log(this); } } user.call(); // ⚙️ Output: {name: 'Mike, call: f}
Source: devdojo.com
javascript this keyword
const refObj = { func: function(){ console.log(this); } };
Source: stackoverflow.com
JavaScript this Keyword
const person = { firstName: "John", lastName : "Doe", id : 5566, fullName : function() { return this.firstName + " " + this.lastName; } };
this javascript
// Im Webbrowser ist das window Objekt das globale Objekt: console.log(this === window); // true a = 37; console.log(window.a); // 37 this.b = "MDN"; console.log(window.b); // "MDN" console.log(b); // "MDN"
Source: developer.mozilla.org