Created
February 13, 2017 15:30
-
-
Save alopatindev/2c12329b350d585312c31cf92f8a5675 to your computer and use it in GitHub Desktop.
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
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