Javascript standard pattern for callback function

Submitted by code_admin on Wed, 07/25/2018 - 15:54
  1. // result is 'Success' or 'Error'
  2. function callback(result, message) {
  3.   if (result === 'Error') {
  4.     console.log('Failed with message ' + message)
  5.   }
  6.   else if (result === 'Success') {
  7.     console.log('Succeeded - message ' + message)
  8.   }
  9.   else {
  10.     console.log('Unknown result')
  11.   }
  12. }

Tags

RJM Article Type
Quick Reference