Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed.
In JavaScript, parameters of functions default to undefined. However, in some situations it might be useful to set a different default value. This is where default parameters can help.
The above code is equivalent to the below ES5 standard code
Functions as parameters
Default parameters are always executed first, function declarations inside the function body evaluate afterwards.
Functions declared in the function body cannot be referred inside default parameters and throw a Error.
The below code throws ReferenceError
Working functions parameter code: