-2

我的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) },
    ]
);
4

1 回答 1

0

!!总是返回布尔值。要么true要么false

在某些语言中nilfalse认为是false布尔表达式,其他一切都被认为是true布尔表达式。

但为了获得布尔真/假,您可以使用!!

于 2013-08-06T08:18:45.220 回答