0

I cannot figure out why in my nested callbacks I can't get my sendKey function to run. I tried this.sendKey, sendkey.sendKey, but neither way worked.

Instead isAlive function is getting called.

var sendkey = this.sendKey;

this.on = function (callbackOn) {
    this.isAlive(function (status) {
        if(status){
            //this.sendKey('KEY_POWER');
            sendkey.sendKey('KEY_POWER');
        }       
        callbackOn("");
    });
};

this.sendKey = function(key, callback) {
    //this code never fires
};
AnKing
  • 1,994
  • 6
  • 31
  • 54
  • converting it all to old style aka function(args){...} did not help to solve problem – AnKing Jul 28 '18 at 20:31
  • You are misunderstanding the keyword `this` in JavaScript. See https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/this. It's all about execution context. – viz Jul 28 '18 at 20:53

0 Answers0