Skip to content

Instantly share code, notes, and snippets.

@jscodelover
Created January 10, 2020 10:43
Show Gist options
  • Save jscodelover/fbe585dc876c76d1cbd545f077a2aa02 to your computer and use it in GitHub Desktop.
Save jscodelover/fbe585dc876c76d1cbd545f077a2aa02 to your computer and use it in GitHub Desktop.
binding class intsance to class method
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