- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- Retry Fail
- Office Politics
- Secret Horror
- Not Impossible
- Monkeys
- Killing Time
- Hypersensitive
- Infallabella
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Edit Admin
What if it's not mobile, but is android and iPhone at the same time?
Edit Admin
Or just plain don't send the whole if() branch of the JS (or send the if() branch without the if(){} around it in the opposite case). Sheesh.
Edit Admin
Or, worse, what if it's mobile, android, iPhone and iPad all at once (where "mobile" means "Windows Mobile", of course...).
Edit Admin
How do you justify calling it "abuse"? I do that frequently. It is correctly using the order . . . what's wrong with that?
Edit Admin
I'm not a JavaScript expert, but can it be that "true" === "true" evaluates to false because these two strings are equal but not identical?
Edit Admin
That would be a pretty severe violation of POLA if
"true" == "true"
and"true" === "true"
weren't bothtrue
.(For the folks who don't know about POLA: "Principle of Least Astonishment".)
Admin
JavaScript has plenty of POLA violations, but I don't think that is one.
Edit Admin
Indeed, it isn't, as revealed by the JS console in Firefox. with == and with ===, the result is the same.
Admin
They're probably not
true
, but are"true"
.Edit Admin
No, they (er, the results of the comparisons) really are (according to the console in Firefox) the booleans rather than strings.
Admin
In JS strings are primitives, meaning their equality logic doesn't follow the same logic as comparing objects(where any two objects are different even with the same contents).
=== really just means it passes the same check as == AND they're the same type.
"1" == 1
is true, but"1" === 1
is false because their type is different.The weird exception to this is the Symbol primitive, which acts like an object in that they're all different on comparisons unless they're the exact same Symbol, even using ==.
Symbol("foo") == Symbol("foo")
is false.Edit Admin
That reminded me of the old joke, "In Heaven, the Germans are the engineers, the French are the cooks and the English are the policemen."
In Heaven, the security is done by iPhone, screen size is by iPad, open source is by Android. I've never used a WinMobile device so I don't know what their strong suits were hahaha