What is the difference between declaring a variable with this in my function than declaring normally using let or var?
const controller = (function() {
  this.name = 'John';
})();
const controller2 = (function() {
  let name = 'Mary';
})();
What is the difference between declaring a variable with this in my function than declaring normally using let or var?
const controller = (function() {
  this.name = 'John';
})();
const controller2 = (function() {
  let name = 'Mary';
})();
this inside your function is window object. So you are not creating a variable, you are adding a property to the window object
console.log((function(){return this})() === window)