tostring 本來是用來做字符串轉(zhuǎn)換的,不過現(xiàn)在流行用來做變量類型的檢查了。網(wǎng)頁(yè)設(shè)計(jì)這里也寫了一個(gè)函數(shù),方便檢查變量的類型,可以用來代替 typeof
執(zhí)行結(jié)果:
gettype("abc"); //string
gettype(true); //boolean
gettype(123); //number
gettype([]); //array
gettype({}); //object
gettype(function(){}); //function
gettype(new date); //date
gettype(new regexp); //regexp
gettype(math); //math
新聞熱點(diǎn)
疑難解答
圖片精選