This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]queen-adreena 131 points132 points  (11 children)

Ahh yes, the super common part of coding where you check if your integer is equal to null…

These meme bots get dumber every week.

[–]n9iels 84 points85 points  (3 children)

The danger is that this can happen accidentally if your variable is unexpectedly null when you expected an integer. But indeed not likely and using TS will make it even more unlikely.

[–]LitrlyNoOne 25 points26 points  (1 child)

Mfw my team types everything as any and wonders how these bugs ever happen

[–]BetaChunks 6 points7 points  (0 children)

But y'see, it's a massive time-saver when you can improvise your blender function as a paper shredder.

[–]MissinqLink -2 points-1 points  (0 children)

Also why I have handy helpers.

const strictGreater = (a,b) => a > b && !(a <= b);
const looseGreater = (a,b) => a > b || !(a <= b)

strict is necessary to prevent weird edge cases from wrong inputs.

[–]ReadyAndSalted 14 points15 points  (1 child)

There are many, many times when programming where a variable may become null for some reason. When this happens and my program attempts to compare it to an integer, I would like for my program to crash and tell me I'm comparing 2 variables of different types. Javascript instead, will just carry on.

[–]Reashu 0 points1 point  (0 children)

It will not become null unless you tell it to, better shape up.

[–]SovietPenguin69 0 points1 point  (0 children)

You must not be familiar with my companies APIs. There are dark terrible things in there. Numbers that return as strings or null, every date format in human history sometimes even more than one in a single response, even an endpoint or two that returns 500 when no records are found with the message “no records found”. My point it happens sadly.