A codebase I'm working on contains many uses of the javascript 'default operator' such as:
var x = y || false;
I'm wondering what the best possible replacement to use in order to guarantee that the value is never undefined, null, etc. Should I replace them with "false" and check against the string? Should I replace them with their longhand counterpart (explicit checks for null and undefined)? Or does each use case need to be evaluated for something I'm not taking into account?
Aucun commentaire:
Enregistrer un commentaire