Skip to content

Instantly share code, notes, and snippets.

@alopatindev
Created February 13, 2017 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alopatindev/2c12329b350d585312c31cf92f8a5675 to your computer and use it in GitHub Desktop.
Save alopatindev/2c12329b350d585312c31cf92f8a5675 to your computer and use it in GitHub Desktop.
let val = 'global 1'
this.val = 'global 2'
console.log('val = ' + val)
class Foo {
constructor() {
this.val = 'property'
}
}
let foo = new Foo()
foo.method = function() {
function test() {
// this is set to the global object
console.log('test this.val=' + this.val)
this.val = 'global 3'
}
test()
}
foo.method()
this.val = 'global 4'
foo.method()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment