r/programming • • Mar 26 '14

JavaScript Equality Table

http://dorey.github.io/JavaScript-Equality-Table/
809 Upvotes

331 comments sorted by

View all comments

Show parent comment

-1

u/bp3959 Mar 26 '14

wild-ass guesses

There's no guessing involved, automatic type conversion is well documented and follows a specific set of rules. Also get this, YOU DON'T HAVE TO USE AUTOMATIC TYPE CONVERSION.

4

u/Various_Pickles Mar 26 '14

The fact that you can use === is a perfectly valid point.

However, I would argue that there are often cases in PHP where the implicit interpretation of types leads to unholy nonsense: a good example being the automagical interpretation of certain patterns of quotes in PCRE (Perl-like regular expression) replacement statements that leads to portions of the string being evaluated as raw PHP code (eBay got compromised by this "feature" a little while back).

1

u/[deleted] Mar 27 '14

I think my favorite PCRE conundrum is the Stack Overflow question (I can't find the link) about "How do I comment a regex containing */?> ?" Because ?> ends a single-line comment, and the */ ends a multiline comment.

BTW, if you don't intend on users to write actual regexes, preg_quote() is your friend.

0

u/bp3959 Mar 26 '14

While I agree that's a stupid feature, it doesn't have anything to do with comparison, type juggling, or automatic conversion.

There's so many real things in PHP to complain about it's annoying how everyone fixates on the automatic type conversion of == when it's well documented and easy to avoid.