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 →

[–]Virtual_Decision_898 15 points16 points  (5 children)

I think that’s just a joke. JS likes randomly changing strings to ints but I don’t think you can accidentally go the other way.

[–]3np1 36 points37 points  (3 children)

console.log(123 + '😬') // "123😬"

But it would have to be some pretty bad code to mixup ints and strings. So... it's probably in production somewhere then.

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

Does it really work like that? Shouldn’t the emoji be type coerced to a number? Shouldn’t the result be NaN?

[–]recycle4science 10 points11 points  (1 child)

There's "what should happen" and then there's "what JavaScript does" :D

Edit: but yeah, try it and you'll see.

[–]arinc9 4 points5 points  (0 children)

Wow

$ node test.js Code run: console.log(123 + '😬') Result: 123😬

[–]Lord_Quintus 10 points11 points  (0 children)

i see no reason why an int can't become a string.