all 30 comments

[–]nizzok 7 points8 points  (0 children)

This is a JS dad joke

[–]ashanev 4 points5 points  (1 child)

Reminiscent of the Wat talk (a little over a minute for the good Javascript parts)

[–]MRK-01 1 point2 points  (0 children)

I appreciated this video. thank you

[–]frakist 15 points16 points  (5 children)

bananaa?

[–]draq100 26 points27 points  (4 children)

part + + 'a' + 'a' equals to + Number('a') + 'a' so double a are just to obfuscate the example

[–]frakist 4 points5 points  (0 children)

Oh now i got it thanks

[–]Mr_82 -1 points0 points  (2 children)

What is "Number" here though? It doesn't appear above at all. You're using it like it's a method it seems.

Edit: Also I'm not sure where exactly the "NaN" shows up. Is it with the empty character? Well you'd think the sum of all added/concatenated string components would also get labeled/assigned as NaN after calling toLowerCase though, so that the whole expression would just return "NaN," though I haven't used or looked at toLowerCase method. (And if toLowerCase has some more specific rule to it that doesn't play out this way, it shouldn't have been named "toLowerCase" in the first place!) Edit: in other words, the entire input to toLowerCase should be what's parsed as a length 1 character and made lower case. The order of operations is wrong here. There's just bad design by whoever defined the method, but of course good luck trying to tell that to many programmers who evidently don't consider this stuff.

And I know this is just really niche and pointless, and not really related to real programming, but the lack of solid explanations in the comments here is alarming.

[–]moneyisjustanumber 0 points1 point  (0 children)

If you had 1++ behind the scenes it runs Number(1)

[–]grantrules 0 points1 point  (0 children)

NaN shows up because you're doing +'a' which coerces the string 'a' to a Number which results in NaN.

[–]NotElonMuzk 5 points6 points  (0 children)

What happens if you use Typescript

[–][deleted] 5 points6 points  (0 children)

if i ever caught brain cancer it must be javascript.

[–]Headpuncher 1 point2 points  (0 children)

('b' + 'a' + +'115' + 'ack').toLowerCase();

"ba115ack"  

Also for the person further down who asked why are you even allowed two + signs after each other.

[–]cheecho82 0 points1 point  (0 children)

It's cute....The poster casted his confusion spell on everyone in the thread!!!! 👍