• (nodebb)

    What if it's not mobile, but is android and iPhone at the same time?

  • (nodebb)

    That's absolutely the wrong way to do that, and I hate it, but there's just so many times you can say, "send server-side values to the client as an object, not inline".

    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.

  • (nodebb) in reply to Mr. TA

    Or, worse, what if it's mobile, android, iPhone and iPad all at once (where "mobile" means "Windows Mobile", of course...).

  • (nodebb)

    we've got some lovely order-of-operations abuse

    How do you justify calling it "abuse"? I do that frequently. It is correctly using the order . . . what's wrong with that?

  • (nodebb)

    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?

  • (nodebb) in reply to Melissa U

    That would be a pretty severe violation of POLA if "true" == "true" and "true" === "true" weren't both true.

    (For the folks who don't know about POLA: "Principle of Least Astonishment".)

  • David-T (unregistered) in reply to Steve_The_Cynic

    JavaScript has plenty of POLA violations, but I don't think that is one.

  • (nodebb) in reply to David-T

    Indeed, it isn't, as revealed by the JS console in Firefox. with == and with ===, the result is the same.

  • Jonathan (unregistered) in reply to Steve_The_Cynic

    if "true" == "true" and "true" === "true" weren't both true

    They're probably not true, but are "true".

  • (nodebb) in reply to Jonathan

    No, they (er, the results of the comparisons) really are (according to the console in Firefox) the booleans rather than strings.

  • Scragar (unregistered) in reply to Melissa U

    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.

  • (nodebb) in reply to Steve_The_Cynic

    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

  • Guessed (unregistered)
    Comment held for moderation.

Leave a comment on “Device Detection”

Log In or post as a guest

Replying to comment #:

« Return to Article