You are viewing a single thread.
View all comments
64 points
  1. You can call it “Java” to enrage other programmers
  2. You can compare numbers against strings without wasting time converting them
permalink
report
reply
11 points

Array(16).join(“wat” - 1) + " Batman!";

permalink
report
parent
reply
5 points
*

JavaScript: :wide eyed and smiling: Sure why not! You’re the boss!

Python: Sighing and downing half a bottle of Advil: Sure. Why not, you’re the boss.

permalink
report
parent
reply
7 points

If you’re living in 2002 and not using the strict equality operator, that’s on you

permalink
report
parent
reply
1 point

But what if I don’t want strict comparison? What if my frontend contains a text field for a numeric input and I wanna manually check against each possible valid input value if (input_val == 1) {...} else if (input_val == 2) {...} else if... without having to convert it first or check that it’s actually a number or fix my frontend?

(I’m sure there are valid use cases for non-strict comparison, I just can’t think of one right now)

permalink
report
parent
reply
4 points
*

why wouldn’t you just convert inline? (Number(input_val) === 2)

Converting would mean you could use a switch statement with your example rather than an if else ladder

switch(Number(input_val)) {
  case 1:
    doTheFirstThing();
  break;
  case 2:
    doTheSecondThing();
  break;
  case 3:
    doTheThirdThing();
  break;
}
permalink
report
parent
reply
3 points
*
Deleted by creator
permalink
report
parent
reply
2 points

The scripting language formerly known as Java.

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 3.6K

    Monthly active users

  • 1.5K

    Posts

  • 35K

    Comments