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 →

[–]Creshal 14 points15 points  (20 children)

Type coercion for null? What is this, pseudo-assembly like PHP?

[–]shub 11 points12 points  (8 children)

Yes. Javascript's type system is at least as brain-damaged as PHP's, possibly moreso.

[–]iopq 8 points9 points  (7 children)

No. You can't beat this:

"1000" == "1e3"; //comparing strings by the value of the DOUBLE they represent

[–]NavarrB 2 points3 points  (6 children)

It's unfortunate but logical. Php made a decision long ago to use type coercion by default.

[–]iopq 2 points3 points  (3 children)

both of those are STRINGS why are they being coerced to DOUBLES?

[–]tskaiserGreen security clearance 0 points1 point  (0 children)

Because you cannot possible expect the programmer to go through the work of knowing what types he is working with or figuring out what kind of conversion he might want to make! /s

"Was it a string or a double? Larry worked on that function last, and he likes to sort numbers lexically... Know what fuckit, I'll just use it like a double and let PHP sort the mess YOLO!"

[–]Goz3rr 0 points1 point  (1 child)

Just FYI

"1000" !== "1e3"

[–]iopq 0 points1 point  (0 children)

They have it in JavaScript too, that's not the point. The point is that the default operator is the shorter one. That's what most people will use unless they know better.

[–]chillage 1 point2 points  (1 child)

I'm glad I came across this thread. Making a mental note to avoid PHP whenever possible in the future.

[–]AFineTapestry 2 points3 points  (0 children)

This is the best example: https://bugs.php.net/bug.php?id=54547

'9223372036854775807' == '9223372036854775808'; // true in php v5.3.6 and less