Created
July 26, 2019 01:02
-
-
Save yasyf/1c79d2c943ec718385bc44c75f6d9c4f 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
class Foo { | |
constructor(name) { | |
this.name = name; | |
} | |
callMeByMyName() { | |
return this.name; | |
} | |
} | |
const logTheImportantReturnValueOf = fn => console.log(`Super important log: ${fn()}`); | |
const foo = new Foo("Yasyf"); | |
console.log(foo.callMeByMyName()); // "Yasyf" | |
logTheImportantReturnValueOf(() => foo.callMeByMyName()); // "Super important log: Yasyf" | |
logTheImportantReturnValueOf(foo.callMeByMyName); // Uncaught TypeError: Cannot read property 'name' of undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment