Last Updated: September 09, 2019
· shekhardesigner

Strict Mode & this keyword in JavaScript

Normally, in global scope this keyword refers to Window object. Eg:

console.log(this); //returns Window object.


    console.log(this); //returns Window object

HOWEVER, in JavaScript strict mode, this keyword in global scope is undefined. Eg:

    "use strict";
    console.log(this); //will return *undefined*

So use the strict mode wisely. Here you can read more fun things about JavaScript Strict Mode: