Created
January 10, 2020 10:43
-
-
Save jscodelover/fbe585dc876c76d1cbd545f077a2aa02 to your computer and use it in GitHub Desktop.
binding class intsance to class method
This file contains 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{ | |
constructor(){ | |
this.name= "manisha" | |
this.demo = this.demo.bind(this); | |
} | |
demo(){ | |
const surname = "basra"; | |
return `${this.name} ${surname}` | |
} | |
} | |
function testA(){ | |
const aa = new A(); | |
return aa.demo; | |
} | |
function testNew(){ | |
const fn = testA(); | |
console.log(fn()); | |
} | |
testNew(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment