re: 3 Ways to Set Default Value in JavaScript VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Given that your "ouchy" if/elses are only checking for truthiness, you'd miss out the a = a; part in the real world, though. // ✅ If/Else is muc...
 
// ✅ Ternary works # Ternary does not work.
a = (a === undefined) ? a : b;

The code in this segment is backwards - you're setting a to a only if it is undefined, and using b in all other cases.

code of conduct - report abuse