3 ms·
I agree that default parameters will be a much nicer solution to this problem, but using the OR operator is a very common practice in JS, and any dev with more
by kevincennis 11y ago
I agree that default parameters will be a much nicer solution to this problem, but using the OR operator is a very common practice in JS, and any dev with more than about 5 weeks experience will recognize and understand that pattern pretty much automatically.
In the example with the undefined check... what if undefined is a valid argument? You should actually check the length of the arguments object.
See, you can always find examples of when you shouldn't do something. That doesn't mean you shouldn't EVER do it. At the end of the day, people who read and write code need to understand how it works. You can only protect people from themselves so much.