It really is a great feature. But be carefull because, the default values only work for undefined. If those functions receive null as values for some arguments with default values, they will be kept as null. I got caught by this so many times :)
undefined
null
Thank you so much for adding this little tidbit! I didn't think to make note of it. :)
A lot of developers, specially beginners can get tricked by this small detail. :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
It really is a great feature.
But be carefull because, the default values only work for
undefined
. If those functions receivenull
as values for some arguments with default values, they will be kept asnull
.I got caught by this so many times :)
Thank you so much for adding this little tidbit! I didn't think to make note of it. :)
A lot of developers, specially beginners can get tricked by this small detail. :)