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
Search - "isempty"
-
Actual production code:
function isEmpty(val) {
return typeof val === 'undefined'
|| val === undefined
|| !(val !== undefined);
}
I'm starting to think the "infinite monkeys" metaphor is not a metaphor...5 -
String nullabity check duel...
null, isEmpty(), "", " ", '', ' ', " null", boolean, NaN, undefined, isNullOrEmpty and finally try-catch -
Few years ago I was looking at legacy code that was developed by offshore team (what could go wrong,right) and I see small utility method that looks like this:
public boolean isEmptyNotEmpty(String s) {
boolean empty=false;
If(s==null) {
empty =true;
}
If(s.equals("")) {
empty = true;
}
return empty;
}
Thinking in myself: was he/she paid per line the line of code??!?!
Up to this date that was the worst part of the code that I encountered....2