How to use optional arguments in functions (with optional callback) – JS Tips – A JS tip per day!

  • shift (); // if last argument is a function then its the callback function const callback = ( typeof args [ args .
  • // pop() removes the last item in the array // and returns it if ( typeof args [ args .
  • pop () : null ; // if args still holds items, these are your optional items which you could retrieve one by one like this: const optionalA = ( args .

Read the full article, click here.


@core_green: “”How to use optional arguments in functions(with optional callback)” #javascript #nodejs #webdev #reactjs #angular2″


Example function where arguments 2 and 3 are optional


How to use optional arguments in functions (with optional callback) – JS Tips – A JS tip per day!