Why write “.call(this)” at the end of a javascript function

(function(){
  "use strict";
  console.log(this);
}).call(this);
(function(){
  console.log(this);
})();

.call(this) is the same as () but ensures your top level this to be consistent trough strict mode.

Tagged:

Leave A Comment?