Nice writeup, thank you very much.
About default arguments it should be mentioned, that the "bad" solution may also cause unexpected errors:
function getValue(val) { const myVal = val || 1; console.log(myVal) } getValue(2) // => 2 getValue(0) // => 1
val may be empty or zero to get the second argument of ||
Thanks.
yeah that's a good one to know as well๐
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.
Nice writeup, thank you very much.
About default arguments it should be mentioned, that the "bad" solution may also cause unexpected errors:
val may be empty or zero to get the second argument of ||
Thanks.
yeah that's a good one to know as well๐