Created
June 8, 2017 07:38
-
-
Save sophistifunk/d273899a3c596ee1dca72b6263df7d8c to your computer and use it in GitHub Desktop.
arrow binding.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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