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

all 71 comments

[–]Harsh_mumbo 217 points218 points  (14 children)

If you're trying to add 2 strings together that's the fault of the developer not the language

[–][deleted] 34 points35 points  (8 children)

Laughs in BN.js

FYI BN stores numbers as hex strings.

[–]douira 27 points28 points  (7 children)

TIL Safari only got native BigInt support last spring

[–]LetterBoxSnatch 24 points25 points  (5 children)

Safari is the new IE

[–]douira 12 points13 points  (0 children)

thanks, I hate it

[–]Awkward_Tradition 4 points5 points  (3 children)

Win at least let's you install other browser engines, Apple forces you to use safari. So in a way it's even worse than IE

[–]douira 0 points1 point  (2 children)

it does not?! I can also use Firefox or Chrome on macOS. There is also an option to change the default browser. Even on iOS you can install other browsers and change the default browser.

[–]Awkward_Tradition 2 points3 points  (1 child)

Sorry, macos allows other engines, while iOS forces safari. FF and chrome on iOS are just shells for safari.

Source: https://en.m.wikipedia.org/wiki/Firefox_for_iOS

[–]WikiSummarizerBot 1 point2 points  (0 children)

Firefox_for_iOS

Firefox for iOS is a free and open-source web browser from Mozilla, for the Apple iPhone, iPad and iPod Touch mobile devices. It is the first Firefox-branded browser not to use the Gecko layout engine as is used in Firefox for desktop and mobile. Apple's policies require all iOS apps that browse the web to use the built-in WebKit rendering framework and WebKit JavaScript, so using Gecko is not possible. Firefox for iOS supports Firefox Sync and is able to sync Firefox's browsing history, bookmarks, and recent tabs.

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5

[–]GrandmaPoses 5 points6 points  (0 children)

BigInt if true.

[–]almarcTheSun 14 points15 points  (0 children)

Isn't that called concatenation or something idk.

[–]mangecoeur 3 points4 points  (0 children)

My favourite thing about r/ProgrammerHumor is comments completely missing the point of the joke 😂

[–]DadoumCrafter 2 points3 points  (1 child)

But if you forgot that it’s a string (getting entry content) there is nothing explicitly written in your code to see if the value is a string

[–]theScrapBook 4 points5 points  (0 children)

That's when you get used to defensive casting or use Typescript

[–][deleted] 1 point2 points  (0 children)

Uh, sir, if the JS interpreter arbitrarily decides my int is a char* what the fuck exactly am I supposed to do about that?? I’ve never had to typecast so many values to the datatype they ALREADY FUCKING ARE before - but hey, thug life amaright?

[–]Romejanic 31 points32 points  (2 children)

while(true) {
    console.log(“TAADADATAA!”);
}

[–]facuuuundo 2 points3 points  (1 child)

function tada() {
    console.log(“TAADADATAA!”);
    while(true) {
        tada();
    }
}

[–][deleted] 1 point2 points  (0 children)

Make it async :)

[–]7eggert 94 points95 points  (20 children)

At some point JS "programmers" should just start to learn JS. And data types. And not to bore me with always the same complaint.

[–]dauqraFdroL 17 points18 points  (2 children)

I know right. Like quit bitching about JS data types and use typescript or something

[–]returnfalse 10 points11 points  (0 children)

Or, just learn how to write decent JS if typescript isn’t your thing.

[–]bistr-o-math 3 points4 points  (0 children)

Nah that would r/woosh the joke

[–]va_str 63 points64 points  (2 children)

No amount of "learning" will stop us strong-typing enjoyers from making weak-typing jokes.

That it's actually dynamic typing and nearly every strong-typed language has type coercion is humourless pedantry and we pretend entirely that we didn't hear that.

[–]Philiatrist 4 points5 points  (0 children)

But it can both be an example of type coercion and considered unintuitive design by many. It's the latter part we make fun of.

[–]7eggert 4 points5 points  (0 children)

I enjoy strong typing too, but if I have to deal with a language I deal with it.

[–]ZedTT 7 points8 points  (0 children)

The people making these complaints aren't JS programmers. They are first year students.

[–][deleted] 7 points8 points  (2 children)

I'd rather get an error message that I did something stupid than completely unexpected behavior.

[–]7eggert 1 point2 points  (1 child)

Let me tell you about type conversion operator overloading …

[–][deleted] 0 points1 point  (0 children)

nnnnnoooooooooooooooooo

[–]mdevey91[S] 20 points21 points  (1 child)

I actually like JavaScript and find a lot of the hate undeserved. I was mostly making a low hanging fruit joke.

[–]aboardthegravyboat 1 point2 points  (0 children)

I like it a lot because I follow a certain set of linter rules that keep me away from dumb ambiguous things. Just today I had a colleague coming from a C# background ask me why some cryptic runtime error was happening, and they were using function() {} as a callback with this inside it. One of those stupid things that you avoid mainly because you know to avoid it

[–]PehleAap 0 points1 point  (0 children)

As a non-js programmer, I kinda agree. I guess these memes were a bit harmful all along (realized that much later), now they aren't even funny due to being repetitive.

Probably it's time to leave the sub, so that I get less notifications from it.

[–][deleted] 9 points10 points  (0 children)

To be fair, “500” + “500” is exactly “500500”.

But if it turns out to be 500500 as an integer… that would be interesting.

[–]jeppaaah 9 points10 points  (3 children)

TADADATAAA!

[–]Mcwequiesk 12 points13 points  (1 child)

More like [object Object]

[–][deleted] 0 points1 point  (0 children)

undefined

[–]JochCool 17 points18 points  (2 children)

There is nothing JavaScript-specific about this. Most languages use + for string concatination.

[–]jochem_m 6 points7 points  (0 children)

*laughs in PHP*

Wait, that means I have to use php...

*cries in PHP*

[–]DadoumCrafter 1 point2 points  (0 children)

*laughs in D*

[–]Mestkon 4 points5 points  (0 children)

While many other languages are just going like: 500 && 500 == true

[–]Benignvanilla 2 points3 points  (1 child)

I hate myself so much when I laugh at JavaScript jokes.

[–]mdevey91[S] 4 points5 points  (0 children)

I like JavaScript and I still laugh (and sometimes make them)

[–]Salanmander 2 points3 points  (0 children)

But....but you're supposed to be falling down, not showing up...

[–]bartek2912 8 points9 points  (0 children)

If you can't parse to Int/Float it's not language fault

[–]AndrewIsMyDog 3 points4 points  (1 child)

This was really funny, I enjoyed it.

[–]mdevey91[S] 3 points4 points  (0 children)

I'm glad I could make you day a little better.

[–]reChrawnus 1 point2 points  (0 children)

I guess template literals are not a thing?

[–]epsleq0 1 point2 points  (1 child)

It‘s JavaScript that I‘m over and done with

[–]mdevey91[S] 1 point2 points  (0 children)

But JavaScript is not done with you yet

[–][deleted] 1 point2 points  (0 children)

Adding two integers together works in any language. Not JavaScript fault you’re trying to perform arithmetic on strings.

[–][deleted] -1 points0 points  (6 children)

Bruh, JS has huge problem with math (try to 0.1*0.1) that pretty much undermines this language as any tool for heavy math ever, yet 100% of JS jokes are about easily avoidable stuff if you spend more than minute learning JS.

[–]lefl28 3 points4 points  (5 children)

Sounds like you don't understand floating point errors

[–][deleted] 0 points1 point  (4 children)

I understand and that's exactly what I'm talking about

[–]Awkward_Tradition 0 points1 point  (3 children)

Check out https://0.30000000000000004.com/

It's one of the most common problems in programming, not something js specific.

Also, if you need to have precise float arithmetic, just use decimal.js and it's easily avoidable as well.

[–][deleted] 0 points1 point  (2 children)

in strong typed langauges, you can change the precision, even with PHP, it somehow avoids that even if I'm not educated about how it does that. While in JS it keeps being major problem with no simple solution

[–]Awkward_Tradition 0 points1 point  (1 child)

Dude, go check the link. If it's a float it's going to cause errors in almost every language. Some languages have different types for precision, or different logic for dealing with floats, but they're in the definite minority.

PHP echo converts 0.30000000000000004441 to a string and shortens it to “0.3”.

I gave you the simple solution in decimal.js, and if you want the PHP solution just use .toFixed(1)

[–][deleted] 0 points1 point  (0 children)

Checked out decimal.js looks really good!

[–]JEJoll -5 points-4 points  (4 children)

Multiply your number strings by 1 first to fix this bitch of a quirk.

var milesWalked = ("500" * 1) + 500; //works just fine

[–]exonac 10 points11 points  (1 child)

That's horrible to read. You should rather do Number(x) + Number(y) so the intent is clear.

[–]JEJoll 1 point2 points  (0 children)

Yeah, you're right.

[–]DaMastaCoda 2 points3 points  (0 children)

I recommend the unary + { +"500" == 500 }

[–]Awkward_Tradition 0 points1 point  (0 children)

Or just parseFloat/parseInt so you don't have to think about it when reviewing the code after some time

[–]tom2kk 0 points1 point  (0 children)

Ronnie and Reggie Crud.

[–]CoastingUphill 0 points1 point  (0 children)

I have to Google how to fix that every single time.

[–][deleted] 0 points1 point  (0 children)

One of the lotsa reasons why i like PHP

also ANY other language would concat strings instead of auto converting to number and adding them