Markuz Shultz
Markuz Shultz

Reputation: 678

Modernizr javascript code explanation

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 !

Upvotes: 1

Views: 257

Answers (1)

Edgar Villegas Alvarado
Edgar Villegas Alvarado

Reputation: 18344

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

Upvotes: 1

Related Questions