I am getting confused regarding the this
keyword in JS. I am not getting how this will work in a standalone function. I referred to many sites, all they are saying is when this
is given in standalone function it will refer to the global object.
In that case for the following code I should get name as "steve" but I am getting undefined. I am trying to understand it but I couldn't pick up how it works.
let name = "Steve";
function sayHelloOne() {
console.log(`Hello, I'm ${this.name}`);
}
sayHelloOne();