-2

Sorry for my possibly naive question, but I am totally novice to JavaScript.

I do not understand this:

return cordova.exec(success || onSuccess, fail || onFail, "Navigation", "exercise", [programId, levelId, orientation]);

The first two arguments are callbacks (success callback and failure callback),

but I do not understand: two callbacks separated by || like success || onSuccess ????

I am confused.

Thanks for your help.

Pointy
  • 405,095
  • 59
  • 585
  • 614
Lisa Anne
  • 4,482
  • 17
  • 83
  • 157

2 Answers2

4

The || operand means "OR", that is, use the success callback if it exists, OR if it does not exist, use onSuccess.

David Hughes
  • 381
  • 1
  • 12
1

success and onSuccess denotes the callback function (same case as fail and onFail)

so in their code their would be something like:

var success = function() { //some stuff here }

var onSuccess = function() { //some stuff apart from success function }

So it is if success function is not their use onSuccess (a fallback function to go to)

V31
  • 7,626
  • 3
  • 26
  • 44