有美一人,清扬婉兮。邂逅相遇,适我愿兮。 ——《诗经·国风·郑风·野有蔓草》

二进制

二进制的英文单词是Binary,二进制的开始是0(零),然后第二个位置是b

   <script>
        let binary = 0B010101;
        console.log(binary)
    </script>

八进制

八进制的英文单词是Octal,也是以0(零)开始的,然后第二个位置是O(欧)

   <script>
        let b= 0o666;
        console.log(b)
    </script>

数字验证Number.isFinite( xx )

       let a = 11/4;
        console.log(Number.isFinite(a)); //true
        console.log(Number.isFinite('jie')); //false
        console.log(Number.isFinite(NaN));//false
        console.log(Number.isFinite(undefined));//false

判断是否为整数Number.isInteger(xx)

    <script>
        // let a = 123.1;
        let a = 123;
        console.log(Number.isInteger(a))//true
    </script>

整数转换Number.parseInt(xxx)和浮点型转换Number.parseFloat(xxx)

    <script>
        let a = '9.18';
        console.log(Number.parseInt(a)); //9
        console.log(Number.parseFloat(a)); //9.18
    </script>

渣渣辉
1.3k 声望147 粉丝