Skip to content

Instantly share code, notes, and snippets.

@yasyf
Created July 26, 2019 01:02
Show Gist options
  • Save yasyf/1c79d2c943ec718385bc44c75f6d9c4f to your computer and use it in GitHub Desktop.
Save yasyf/1c79d2c943ec718385bc44c75f6d9c4f to your computer and use it in GitHub Desktop.
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