ES5 doesn't offer support for default parameters. So, as a result, we all ended up resorting to less-than-ideal alternatives (like
name = name || 'Joe'). Luckily, with ES6, it'll all just work the way you'd expect. Even better, you're not limited to primitives alone; you can even set the default value equal to the result of a function call!
Published on May 2nd, 2016.
Understand.io is used by hundreds of Laravel developers to find and fix errors.
Sign up for a free 14-day trial now.