isLoaded在jQuery上的目的?

时间:2013-08-06 08:05:07

标签: jquery

我的start.js文件中有以下jQuery代码。我的问题是,有人能告诉我isLoaded: !!(window.jQuery && jQuery.cookie)代码段的作用吗?

Sys.loader.defineScripts(
    {
        releaseUrl: '~/scripts/jquery/{0}/jquery.{0}.min.js',
        debugUrl: '~/scripts/jquery/{0}/jquery.{0}.js'
    }, 
    [
        { name: 'blockUI', dependencies: ['jQueryUI'], isLoaded: !!(window.jQuery && jQuery.blockUI) },
        { name: 'rating', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.rating) },
        { name: 'watermark', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.fn.watermark) },
        { name: 'mousewheel', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.event.special.mousewheel) },
        { name: 'cookie', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.cookie) },
        { name: 'tmpl', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.fn.tmpl) },
        { name: 'maskedinput', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.fn.maskedinput) },
        { name: 'ba-bbq', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.bbq) },
        { name: 'validate', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.fn.validate) },
        { name: 'form', dependencies: ['jQuery'], isLoaded: !!(window.jQuery && jQuery.fn.ajaxForm) },
    ]
);

1 个答案:

答案 0 :(得分:0)

!!总是返回布尔值。 truefalse

在某些语言中,nilfalse在布尔表达式中视为false,其他所有语言都被视为布尔表达式的true

但为了获得布尔值true / false,您可以使用!!