Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
alexteg318yThere could actually be a purpose to this in JavaScript, even though it could be written more concisely.
Not having strict equals means falsy values like 0, "" or undefined will be turned into null.
Coffeescript turns the existential operator for something like:
foobar?
into
(foobar != null)
for this specific purpose of catching all falsy values. -
sandeepb3038yI sometimes write code like this mainly so I can add extra logic in the future. Saves time down the line.
-
//stuff here
unsigned int v;
// more stuff here
If (v <0){
//Do Something of Important(*)
}
//again stuff -
andys8838yThis makes total sense in JS. It will return both null and undefined as null, but pass valid values trough (especially relevant for falsy ones like "" and 0).
Related Rants

Enough said
I don't understand why people like an app but give it the lowest rating because they want more
The worst Code I saw was
if (value != null ) {
return value;
} else {
return null;
}
undefined
wk58
logic gem