Created
August 7, 2013 09:05
-
-
Save senz/6172452 to your computer and use it in GitHub Desktop.
getting global object from random places and behavior in strict mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
"use strict"; | |
var obj = {lolo: 1}; | |
console.log("ljambda this in strict:", (function(){ return this === undefined; })()); | |
(function() { | |
console.log("current context:", this); | |
var Fn = Function, global = new Fn('"use strict"; return this')(); | |
console.log("evaled func this is (strict): ", global); | |
var Fn = Function, global = new Fn('return this')(); | |
console.log("evaled func this is (non-strict): ", global); | |
}).apply(obj); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment