在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ jQuery的isNumeric疑惑

jQuery的isNumeric疑惑

貼上jQuery的源碼

    isNumeric: function( obj ) {

        // As of jQuery 3.0, isNumeric is limited to
        // strings and numbers (primitives or objects)
        // that can be coerced to finite numbers (gh-2662)
        var type = jQuery.type( obj );
        return ( type === "number" || type === "string" ) &&

            // parseFloat NaNs numeric-cast false positives ("")
            // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
            // subtraction forces infinities to NaN
            !isNaN( obj - parseFloat( obj ) );
    },

為什么需要obj - parseFloat( obj )而不是直接obj - obj
是為了排除什么情況?

在問(wèn)題補(bǔ)充回答。
空字符串的情況

回答
編輯回答
陪我終

true

2018年6月24日 01:04
編輯回答
青瓷
 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")

注釋里已經(jīng)寫(xiě)的很明白了啊

2017年10月22日 03:52