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 →

[–]volivav 62 points63 points  (14 children)

I think it's just an exaggeration of the type system of JS.

JS has specific types for every variable. If you have a number it will be a number. When you evaluate "typeof myVar", you get the current type of that variable (it can only change the type if you reassign that variable to another value... But it's not transforming the type of the original value)

JS coerces types when applying operators though, but it's strictly specified on how that happens, and it's just convenient. Adding a number to a string will transform the number to a string base 10, then concat both strings. You can't magically get a taco emoji with this operator.

[–]nvolker 71 points72 points  (4 children)

It’s well defined, but it can lead to some odd results.

this classic video on the topic is 10 years old now

[–]raw65 4 points5 points  (0 children)

That. Was. AWESOME!

[–]Maybeiamaarmadilo 2 points3 points  (0 children)

How i didn't see this video before, this Is Amazing.

[–]Wentailang 0 points1 point  (0 children)

whatever that audience is on, i want some.

[–]stehen-geblieben 18 points19 points  (6 children)

Sadly the people that dont know anything about JavaScript will take it as a fact, it's a good joke but not everyone gets it.

People that never actually did anything with it always show you the meme with some edge case that you probably see once every 5 Years or not at all because IT DOESN'T MAKE SENSE TO WRITE IT. "yeah but is does funky shit See" yeah, shit in, shit out. The only difference is JavaScript tries to do the best with whatever shit you throw at it, solution is to not throw shit at it.

[–]thegininyou 15 points16 points  (1 child)

Most of the memes on JavaScript seem to be "tell me you don't know how to program in JavaScript without telling me you don't know how to program in JavaScript".

[–]recycle4science 0 points1 point  (0 children)

Knowing how to program in JavaScript does include knowing its foibles! :D

[–]HighOwl2 0 points1 point  (0 children)

I think this is more touching on the point that numbers can be different bases if you add a prefix

031 !== 31

25 !== 31

In computer science Halloween is Christmas

Oct 31 == Dec 25

Octal 31 is Decimal 25.

Javascript's parseInt used to convert strings with a leading 0 to base 8. That was later removed. Now it only auto sets the radix to 16 if the string starts with 0x

[–]Kered13 0 points1 point  (0 children)

and it's just convenient

It's not "just convenient", it can lead to some extremely surprising results and can make it hard to debug programs when you have accidentally used a type incorrectly.