Skip to content

Instantly share code, notes, and snippets.

@CodHeK
Created June 8, 2020 16:40
Show Gist options
  • Save CodHeK/05f6b83acf0372450643befbdec077a7 to your computer and use it in GitHub Desktop.
Save CodHeK/05f6b83acf0372450643befbdec077a7 to your computer and use it in GitHub Desktop.
const obj = {
prop: 'Hello',
method: function() {
setTimeout(() => {
console.log(this.prop + ', World!'); // Hello, World!
}, 2000);
}
};
obj.method();
/* ------------------------ OR -------------------------------- */
const obj = {
prop: 'Hello',
method: function() {
const inner = () => {
console.log(this.prop + ', World!'); // Hello, World!
}
inner();
}
};
obj.method();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment