1

I'm working on some HTML5 template and I'm watching some examples on the internet how other guys done it , since I would like to put my work on Theme Forest , I found this peace of code in one of examples and I really cant get it how it works . So please if anyone could help me to understand this it would be great

var pd = {},
verboseBuild = !0,
screenXs = 480,
ltIE9 = !1;

/* Modernizer */

!$("html").is(".lt-ie9") || (ltIE9 = !0),

Modernizr.addTest("ipad", function () {
    return !!navigator.userAgent.match(/iPad/i);
}),
Modernizr.addTest("iphone", function () {
    return !!navigator.userAgent.match(/iPhone/i);
}),
Modernizr.addTest("ipod", function () {
    return !!navigator.userAgent.match(/iPod/i);
}),
Modernizr.addTest("appleios", function () {
    return Modernizr.ipad || Modernizr.ipod || Modernizr.iphone;
}),
Modernizr.appleios && $("html").addClass("ios-device"),
    !verboseBuild || console.log("Starting builds:"),
    $(document).ready(function () {
        !verboseBuild || console.log("-- starting proton.common build"), 
        pd.common.build();
    }),

and can anyone explain what verbosebuild = !0 mean and itE9 = !1 too?

Thanks !

1 Answer 1

1

Well:

  • !0 is just an alias for true
  • !1 is just an alias for false
  • !!<something> in simple words, casts <something> to boolean (will always return true or false)

(Btw, I don't know the reasons why their developers did the first 2, In my opinion, that would be microoptimization, that shouldn't be done).

So, for example:

ltIE9 = !1 means IE version is 9 or higher

Hope this helps. Cheers

Sign up to request clarification or add additional context in comments.

3 Comments

Just curious, how is !1 a microoptimization? Doesn't JS have to evaluate 1 to true first? I would've that that false would've been faster than !1
I'm not sure if it is, but I couldn't think of other reason they did it. Why do you think they did it?
Misguided ego, is my opinion. Seasoned developers will know the developer who wrote this is just blowing hot air, novice developers will be "impressed" (unfortunately) by the abstract and unusual syntax and think that the developer that wrote this must know something that they don't. Ultimately, !0 and !1 is absolutely nonsense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.