Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
Yes in fact, Thank you for spreading more light on that path. That's why the default function parameters is indeed a boon to JavaScript. We're saved from these quirks that could leave us banging our heads on our monitors all day long!... Thanks for reading and happy coding!!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Default values are one of the best additions to JavaScript.
I'd like to mention in this example, using the
||
short circuit evaluation will result in bugs.In this example,
getSum(0, 0)
will return42
.The reason is
0
isfalsy
and therefore will result in1
fora
and41
forb
.Cheers!
Yes in fact, Thank you for spreading more light on that path. That's why the default function parameters is indeed a boon to JavaScript. We're saved from these quirks that could leave us banging our heads on our monitors all day long!... Thanks for reading and happy coding!!