In order to help us create more flexible functions, ES6 introduces default parameters for functions.
- Ex:
const increment = (number, value = 1) => number + value;
console.log(increment(5)); will display 6
console.log(increment(5, 2)); will display 7
As you can see in the example above, we added a default parameter so that it will add 1 to number if value is not specified.
Top comments (0)