ES6 provides a new syntax to assign default values to function parameters. You might be familiar with this concept from languages like Ruby, PHP or C++ and it’s about time that this was baked into the language.
One of the ways of checking for default values in ES5 code was to check if the parameter was
Here is a contrived example:
Let’s look at the same example using default function parameters and some ES6 template strings sugar.
Default value expressions
Default values can be valid expressions and even functions. The contrived code samples below demonstrates this.