I have Used this keyword in Java Script many times but One thing that confuses me is how the this keyword works. Put simply, this is a referencing alias—it’s just knowing what exactly it references. I didn't get clear understanding of how this works.
For Example The code sample below
var car = 'swift';
var myCar = {car: 'Honda city'};
var getCar = function() {
console.log(this.car);
};
myCar.getCar = getCar;
myCar.getCar();
// output: Honda City
getCar();
// output: swift