Skip to content

Instantly share code, notes, and snippets.

@phobal
Created December 29, 2020 03:21
Show Gist options
  • Select an option

  • Save phobal/9f02a9554c8115abcd27657efbb700b0 to your computer and use it in GitHub Desktop.

Select an option

Save phobal/9f02a9554c8115abcd27657efbb700b0 to your computer and use it in GitHub Desktop.
const a = {
a: 'a'
};
const obj = {
getThis: () => this,
getThis2 () {
return this;
}
};
obj.getThis3 = obj.getThis.bind(obj);
obj.getThis4 = obj.getThis2.bind(obj);
const answers = [
obj.getThis(),
obj.getThis.call(a),
obj.getThis2(),
obj.getThis2.call(a),
obj.getThis3(),
obj.getThis3.call(a),
obj.getThis4(),
obj.getThis4.call(a)
];
console.log(answers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment