DEV Community

Discussion on: Javascript Shorthand Coding Techniques

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

12 and 15 is well-known to be quite dangerous, that is why rather than

let c = a || b  // All falsy value is short circuited.

This is safer

let c = a ?? b  // Does not short circuit '', 0, NaN; only null and undefined

Without ??, I do have to write my own utility function sometimes.

Collapse
 
ayekpleclemence profile image
Ayekple Clemence

Thanks