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
-
@j4cobgarby worst of all, they copy-pasted the function right above it and added some code at the end of the copy. They propably didn't realize they could use the result from the previous function...
-
@bashleigh it's something like
arr = this.someOtherFunc();
return arr[0] !== undefined ? arr[0].id: undefined; -
@PonySlaystation i should do this at work, now i only need someone to certify this perfectly valid medical condition
-
@Vitz it's javascript. Javascripts == operator has a history of fails, based on the design of the language. E.g. [[[2]]] == 2 returns true, same for 0 == "\t".
Because of that the === operator was introduced which also checks the types of the operands -
Djanjo4497y@YouAreAPIRate
You don't have an equals or instanceof? 3 times =? Seriously? Who is the genius to make that up...
Good thing they stopped at 3.... Moreover Javascript not smart enough to realize when 2 different types are being compared... -
@Vitz there is a typeof, but what do you prefer?
a === b
Or
typeof a == typeof b && a == b
That's just the way a language born from browser wars works, it's the same with html parsing. Every browser had his own rules and exceptions and then there's backwards compatibility. -
Djanjo4497y@YouAreAPIRate
I would prefer a.equals(b) for value and == for reference.
Or even better, never check for null unless it's on the UI level, always return empty objects because you can iterate them because it will just do nothing.
Related Rants
If got to do some bugfixing at work today.
Looking through code:
if (x !== undefined || x !== null){
I want the person who wrote this to wear the ugliest and scratchiest christmas sweater with "i write bad code" written on it
rant
bad code
javascript
annoyed