-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
  • 389,373
  • 58
  • 564
  • 602
Lisa Anne
  • 4,654
  • 16
  • 75
  • 151

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,598
  • 3
  • 25
  • 44