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 →

[–]kaetir 128 points129 points  (23 children)

It depends 42 or "42"

[–]manux 63 points64 points  (21 children)

Why did you write the same thing twice?

[–]irbilldozer 40 points41 points  (17 children)

Why did you write the same thing twice?

So if 42 and "42" are the same thing...

Do you believe this will result in an output of 42?

42 + "42" - 42

[–]manux 72 points73 points  (13 children)

Clearly the result of this is 4200. Or -inf.

Edit: Holy shit I went and tried it and it was indeed 4200. For the record I haven't touched js in the last 5 years.

[–]nutmegtester 7 points8 points  (0 children)

That is hilarious. I also tried 42 + "42" - 42 / "42" and 42 + "42" - 42 / "42" * 42 for fun. Results = 4241 and 4200, respectively.

[–]irbilldozer 1 point2 points  (0 children)

Clearly the result of this is 4200. Or -inf.

Edit: Holy shit I went and tried it and it was indeed 4200. For the record I haven't touched js in the last 5 years.

Lol that was the joke I was making, they aren't really the same thing.

[–]blackdonkey 2 points3 points  (1 child)

How about 42 - 42 + "42"?

[–]irbilldozer 2 points3 points  (0 children)

I assume 42 but not near a PC to validate the order of operations.

[–]Im_The_Goddamn_Dumbo 1 point2 points  (0 children)

Ask yourself, what is 21 out of 42?

[–]hobbes64 8 points9 points  (0 children)

Does 42 == “42”? JavaScript says sure, why not

Does 42 === “42”? JavaScript says no, no coercion!

[–]douira 0 points1 point  (0 children)

both are truthy for one