Number() 函數把對象的值轉換爲數字。數組
Number(object);參數必須是對象
若是對象的值沒法轉換爲數字,那麼 Number() 函數返回 NaN。函數
① var arr = [1000]; var val = 1; console.log(arr+val); //10001 ② var arr = ['1000']; var val = 1; console.log(arr+val); //10001 ③ var str= '["1000"]'; var val = 1; console.log(str+val); //["1000"]1 ④Number參數是數組 var arr = ['1000']; var val = 1; console.log(Number(arr)+val);//1001 ⑤Number參數是Date對象 console.log(new Date().getTime(),'\n',Number(new Date())); //1552900432871 1552900432871