-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs_one_yuan.html
More file actions
55 lines (48 loc) · 1.94 KB
/
js_one_yuan.html
File metadata and controls
55 lines (48 loc) · 1.94 KB
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
<!--
* @由于个人水平有限, 难免有些错误, 还请指点:
* @Author: cpu_code
* @Date: 2020-10-17 20:39:33
* @LastEditTime: 2020-10-17 22:48:38
* @FilePath: \web\javascript\js_one_yuan\js_one_yuan.html
* @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code)
* @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code)
* @CSDN: [https://blog.csdn.net/qq_44226094](https://blog.csdn.net/qq_44226094)
* @Gitbook: [https://923992029.gitbook.io/cpucode/](https://923992029.gitbook.io/cpucode/)
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>一元运算符</title>
<script>
/*
1. 一元运算符:只有一个运算数的运算符
++,-- , +(正号) -(负号)
* ++ --: 自增(自减)
* ++(--) 在前,先自增(自减),再运算
* ++(--) 在后,先运算,再自增(自减)
* +(-):正负号
* 注意:在JS中,如果运算数不是运算符所要求的类型,那么js引擎会自动的将运算数进行类型转换
* 其他类型转number:
* string转number:按照字面值转换。如果字面值不是数字,则转为NaN(不是数字的数字)
* boolean转number:true转为1,false转为0
*/
var num = 11;
var a = ++num;
document.write(num);
document.write(a);
document.write("<hr>");
var b = +"aab";
document.write(typeof(b) + "<br>");
document.write(b + 1 + "<br>");
document.write("<hr>");
var flag = +true;
var f2 = +true;
document.write(typeof(flag) + "<br>");
document.write(flag + "<br>");
document.write(f2 + "<br>");
</script>
</head>
<body>
</body>
</html>