Home  >  Article  >  Web Front-end  >  Detailed explanation of new judgments about numbers in ES6

Detailed explanation of new judgments about numbers in ES6

php中世界最好的语言
php中世界最好的语言Original
2018-03-10 14:21:432035browse

This time I will bring you a detailed explanation of the judgment of new numbers in ES6. What are the precautions about the judgment of new numbers in ES6. The following is a practical case, let's take a look.

    var binary = 0B010101; //声明二进制数;0B开头;
    var octol = 0O666; //声明八进制数;0O开头;(零与字母O)
    console.log(binary, octol) //十进制输出  21 438;
    //判断是否是数字:(整数小数都返回true;其他为false;)
    console.log(Number.isFinite(binary)); //ture;
    //判断是否是非数字;
    console.log(Number.isNaN(NaN)); //true;
    // 判读是否是整数
    console.log(Number.isInteger(11));
    //数的转换;
    let a = '9.18';
    console.log(Number.parseInt(a));
    console.log(Number.parseFloat(a));
    //最大安全整数:// 9007199254740991
    console.log(Number.MAX_SAFE_INTEGER);
    //最小安全整数:// -9007199254740991
    console.log(Number.MIN_SAFE_INTEGER);
    //安全整数判断;//false
    console.log(Number.isSafeInteger(9007199254740992)); //false;

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!

Related reading:

Detailed explanation of the expansion operator of ES6

Detailed explanation of destructuring assignment of ES6

Detailed explanation of scope and declaration of variables in ES6

The above is the detailed content of Detailed explanation of new judgments about numbers in ES6. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn