1. 程式人生 > >js判斷資料型別是哪種

js判斷資料型別是哪種

var   gettype=Object.prototype.toString

        gettype.call('aaaa')        輸出      [object String]

        gettype.call(2222)         輸出      [object Number]

        gettype.call(true)          輸出      [object Boolean]

        gettype.call(undefined)  輸出      [object Undefined]

        gettype.call(null)                  輸出   [object Null]

         gettype.call({})                   輸出   [object Object]

         gettype.call([])                    輸出   [object Array]          gettype.call(function(){})     輸出   [object Function]