It is generally considered that this is not allowed to point to global objects in strict mode.
such as: http://www.ruanyifeng.com/blog/2013/01/javascript_strict_mode.html
It is necessary to note that this is not a problem in itself pointing to the global .
Example code:
<!DOCTYPE HTML><HTMLLang= "zh"> <Head> <MetaCharSet= "UTF-8" /> <title>Strict mode this points to the</title> </Head> <Body> <Scripttype= "Text/javascript"> 'Use Strict'; Console.log ( This); </Script> </Body></HTML>
The console output is a window object (Global object):
Strict mode This does not allow pointing to global objects refers to the inside of a function, as in the following sample code:
<!DOCTYPE HTML><HTMLLang= "zh"> <Head> <MetaCharSet= "UTF-8" /> <title>Strict mode this points to the</title> </Head> <Body> <Scripttype= "Text/javascript"> 'Use Strict'; functionF () { This. A= 1; //this pointer to the global this does not }; F (); </Script> </Body></HTML>
Console output Error:
JavaScript in strict mode this points to the