How do I access a class property within a nested function?
Consider the following code:
class Person{
constructor(name){
this.name = name
}
findFromDatabase(name){
return new Promise(function(resolve,reject)){
this.userData = DatabaseMethod(name) // This binds userData to the promise
})
}
}
I intend to bind userData
to the Person
class, but using this.userData = ...
Binds it to the promise. How can I achieve what I intended to do? Thanks.