I have the following module Dog
. I want to call the member function wagTail()
every time I call walk()
, because it is a happy dog.
class Dog {
constructor(name){
this.name = name
}
walk(){
doAsyncStuffToMoveLegs((error) => {
if(!error) {
this.wagTail()
}
})
}
wagTail(){
// initiate tail wagging :)
}
}
module.exports = {Dog: Dog}
I get the following error:
TypeError: Cannot read property 'wagTail' of undefined.
What am I doing wrong?