Skip to content

Instantly share code, notes, and snippets.

@obetame
Last active September 13, 2020 06:45
Show Gist options
  • Save obetame/fc116a92209b0f1ca27e03114564f0a4 to your computer and use it in GitHub Desktop.
Save obetame/fc116a92209b0f1ca27e03114564f0a4 to your computer and use it in GitHub Desktop.
var age = 2;
const person = {
age: 1,
doSomething(name) {
console.log(this === person);
console.log(this.age);
console.log(name);
},
};
const extractFn = person.doSomething;
extractFn('rick'); // false 2 rick
extractFn.call(person, 'rick'); // true 1 rick
extractFn.apply(person, ['rick']); // true 1 rick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment