Last active
August 20, 2019 20:47
-
-
Save W-Mills/dee060f4d52c84b1263aeb6d61091c9f to your computer and use it in GitHub Desktop.
Clarifying this in JavaScript example 2
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
const foo = { | |
bar: 'baz', | |
getBar: function() { | |
console.log(this.bar); | |
}, | |
}; | |
let qux = foo.getBar; | |
qux.call(foo); // logs 'baz' | |
qux(); // logs undefined | |
qux.apply(foo); // logs 'baz' | |
qux(); // logs undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment