javascript - Why "this" inside of a function's returning object window -


there 2 type of scope in javascript named function scope global scope

now executing code

function abc() { alert(this); } abc(); 

abc call returning me [object window] why?? function makes scope why representing window

this, inside function, object on function invoked. in case, not invoking on object. so, default this refer global object, in browser, window object.

but in strict mode, if invoke this, this undefined.

"use strict"; function abc() {     console.log(this);    // undefined } abc(); 

or

function abc() {     "use strict";     console.log(this);   // undefined } abc(); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -