Skip to content

Instantly share code, notes, and snippets.

@sophistifunk
Created June 8, 2017 07:38
Show Gist options
  • Save sophistifunk/d273899a3c596ee1dca72b6263df7d8c to your computer and use it in GitHub Desktop.
Save sophistifunk/d273899a3c596ee1dca72b6263df7d8c to your computer and use it in GitHub Desktop.
arrow binding.js
class A {
__identify() {
return "Class A"
}
idNotBound() {
return this.__identify()
}
idBound = () => {
return this.__identify()
}
}
class B extends A {
__identify() {
return "Class B"
}
}
console.log("A bound ==", new A().idBound());
// => A bound == Class A
console.log("A not bound ==", new A().idNotBound());
// => A not bound == Class A
console.log("B bound ==", new B().idBound());
// => B bound == Class B
console.log("B not bound ==", new B().idNotBound());
// => B not bound == Class B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment