Number Type
The number type represents a numeric type, including integral and floating-point types. JS in the long shape, short integer, single-precision, double-precision.
Number definition
The number type is defined as follows, the first of which is most commonly used. The latter two are generally not used.
var1;varnewNumber(); //初始值为0varnewNumber(1);
Number types are integral and floating-point
var1; //整型var2.3; //浮点
Infinity
- is a numeric type
- Represents a value that exceeds the JavaScript processing range
- Any divisor divided by 0, also infinity
//在谷歌控制台中输入typeofInfinity"number"//--------------------------var6/0Infinity//但是直接使用 typeof 6/0 最后的结果是NaNtypeof6/0NaN
NaN
- is also a numeric type
- If the calculation fails, the result is Nan
- Contagious, if there is a nan in the arithmetic operation, it causes the whole arithmetic to fail
//在谷歌控制台中输入typeofNaN"number"//--------------------------var6‘s‘NaN
typeof operator and typeof () function
typeof is used to determine the type of variable, usage:
var0vartypeof s;if(typeof‘number‘);typeof(s)
Here you only understand the usage of typeof
Note:
typeof is an operator and not a function, and typeof () is a function.
Undefined and null
Typically, when we access an unassigned variable, we get a undefined value.
Null means null and nothing.
JavaScript variable type