{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4183","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4183/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4183/comments","events_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4183/events","html_url":"https://github.com/HaxeFoundation/haxe/issues/4183","id":71678586,"number":4183,"title":"javascript code fails in SpiderMonkey","user":{"login":"ktimothy","id":1556432,"avatar_url":"https://avatars.githubusercontent.com/u/1556432?v=3","gravatar_id":"","url":"https://api.github.com/users/ktimothy","html_url":"https://github.com/ktimothy","followers_url":"https://api.github.com/users/ktimothy/followers","following_url":"https://api.github.com/users/ktimothy/following{/other_user}","gists_url":"https://api.github.com/users/ktimothy/gists{/gist_id}","starred_url":"https://api.github.com/users/ktimothy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktimothy/subscriptions","organizations_url":"https://api.github.com/users/ktimothy/orgs","repos_url":"https://api.github.com/users/ktimothy/repos","events_url":"https://api.github.com/users/ktimothy/events{/privacy}","received_events_url":"https://api.github.com/users/ktimothy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-04-28T19:24:00Z","updated_at":"2015-04-28T19:36:47Z","closed_at":null,"body":"When running javascript on SpiderMonkey VM, it fails on accessing ```global``` variable.\r\n\r\n```javascript\r\njs.Boot.__resolveNativeClass = function(name) {\r\n\tif(typeof window != \"undefined\") return window[name]; else return global[name];\r\n};\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/comments/97179921","html_url":"https://github.com/HaxeFoundation/haxe/issues/4183#issuecomment-97179921","issue_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4183","id":97179921,"user":{"login":"mcheshkov","id":1045163,"avatar_url":"https://avatars.githubusercontent.com/u/1045163?v=3","gravatar_id":"","url":"https://api.github.com/users/mcheshkov","html_url":"https://github.com/mcheshkov","followers_url":"https://api.github.com/users/mcheshkov/followers","following_url":"https://api.github.com/users/mcheshkov/following{/other_user}","gists_url":"https://api.github.com/users/mcheshkov/gists{/gist_id}","starred_url":"https://api.github.com/users/mcheshkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcheshkov/subscriptions","organizations_url":"https://api.github.com/users/mcheshkov/orgs","repos_url":"https://api.github.com/users/mcheshkov/repos","events_url":"https://api.github.com/users/mcheshkov/events{/privacy}","received_events_url":"https://api.github.com/users/mcheshkov/received_events","type":"User","site_admin":false},"created_at":"2015-04-28T19:36:47Z","updated_at":"2015-04-28T19:36:47Z","body":"That's because you didn't introduce a variable in a scope that masks global.\r\n\r\n    > typeof(global) == 'undefined'\r\n    false\r\n    > function(){ if(typeof(global) == 'undefined'){var global = this; return \"assigned\";} return \"not assigned\";}()\r\n    'assigned'\r\n"}}