-
Notifications
You must be signed in to change notification settings - Fork 0
/
07.Number.html
57 lines (47 loc) · 1.64 KB
/
07.Number.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
/*
在JS中所有的数值都是Number类型,包括整数和浮点数(小数)
JS中可以表示的数字的最大值
Number.MAX_VALUE
1.7976931348623157e+308
Number.MIN_VALUE 大于0的最小值
5e-324
如果使用Number表示的数字超过了最大值,则会返回一个
Infinity 表示正无穷
-Infinity 表示负无穷
使用typeof检查Infinity也会返回Number
NaN 是一个特殊的数字,表示不是数字
*/
//数字123
var a=123;
//字符串123
var b="123";
/*
可以使用一个运算符typeof
来检查一个变量的类型
语法:typeof 变量
检查字符串时,会返回string
检查数值时,会返回number
*/
// console.log(typeof a);
a=Infinity;
/*
在JS中整数的运算基本可以保证精确
如果使用JS进行浮点运算,可能得到一个不精确的结果
所以千万不要使用JS进行对精确度要求比较高的运算
*/
console.log(Number.MAX_VALUE);
console.log(a);
console.log(b);
console.log(typeof a);
</script>
</head>
<body>
</body>
</html>