The ES6 way

default values and using a variable number of arguments in functions

We'll cover the following...

ES6 supports default values. Whenever an argument is not given, the default value is substituted. The syntax is quite compact:

Press + to interact
function addCalendarEntry(
event,
date = new Date().getTime(),
len = 60,
timeout = 1000 ) {
return len;
}
var add=addCalendarEntry( 'meeting' );
console.log(add); //outputs the default value set earlier

Suppose function f is given with two arguments, a and b. ...