Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
Last active November 5, 2017 02:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DmitrySoshnikov/61a97a6c56afc8a83e833e95b2b1cc8c to your computer and use it in GitHub Desktop.
Save DmitrySoshnikov/61a97a6c56afc8a83e833e95b2b1cc8c to your computer and use it in GitHub Desktop.
/**
* JavaScript dynamic `this` value.
*/
function produce() {
console.log(this.x);
}
const alpha = {produce, x: 1};
const beta = {produce, x: 2};
const gamma = {produce, x: 3};
console.log(
alpha.produce(), // 1
beta.produce(), // 2
gamma.produce(), // 3
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment