8 Different Places “this” Can Point to in JavaScript

https://blog.bitsrc.io/where-exactly-does-this-point-to-in-javascript-2be1e3fad1fd

Function context

var name = "window";
var doSth = function () {
  console.log(this.name);
};
doSth(); // 'window'
let name2 = "window2";
let doSth2 = function () {
  console.log(this === window);
  console.log(this.name2);
};
doSth2(); // true, undefined