Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created January 20, 2011 19:09
Show Gist options
  • Save isaacs/788414 to your computer and use it in GitHub Desktop.
Save isaacs/788414 to your computer and use it in GitHub Desktop.
var a = 1
this.b = 2
global.c = 3
d = 4
exports.e = 5
console.log({a: {global:global.a, this:this.a, exports:exports.a, t:typeof a}
,b: {global:global.b, this:this.b, exports:exports.b, t:typeof b}
,c: {global:global.c, this:this.c, exports:exports.c, t:typeof c}
,d: {global:global.d, this:this.d, exports:exports.d, t:typeof d}
,e: {global:global.e, this:this.e, exports:exports.e, t:typeof e}
})
console.log( global === (function(){return this}).call() )
// result:
// { a:
// { global: undefined
// , this: undefined
// , exports: undefined
// , t: 'number'
// }
// , b:
// { global: undefined
// , this: 2
// , exports: 2
// , t: 'undefined'
// }
// , c:
// { global: 3
// , this: undefined
// , exports: undefined
// , t: 'number'
// }
// , d:
// { global: 4
// , this: undefined
// , exports: undefined
// , t: 'number'
// }
// , e:
// { global: undefined
// , this: 5
// , exports: 5
// , t: 'undefined'
// }
// }
// true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment