|
|
|
|
|
by raju
4913 days ago
|
|
I am not sure that's quite what you want. Declaring x as a 'var' does not make it a property on the global object. Your example will return an 'undefined'. I think this is what you want "use strict";
this.x = 1;
var ret = (function() {
"use strict";
return this.x;
}).call(this);
console.log(ret); //returns 1
|
|
In global scope, the activation object is the global object, and so saying "var x = 1" will make the global object have a property x equal to 1.