1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title></title>
6 <script type="text/javascript">
7
8 var n1=10;
9 var n2=20;
10
11 var n = n1++; //后置,先赋值,即n=10,再n1自增1为11
12
13 console.log(n); //10
14 console.log(n1); //11
15
16 n = ++n1 //前置,n1先自增1为12,再赋值给n,即n为12
17 console.log(n); //12
18 console.log(n1); //12
19
20 n = n2--; //后置,先把n2赋值给n,即n为20,再自减1,则n2为19
21 console.log(n); //20
22 console.log(n2); //19
23
24 n = --n2; //前置,n2先自减1,即n2为18,再赋值给n,即n为18
25 console.log(n); //18
26 console.log(n2); //18
27
28
29
30 </script>
31 </head>
32 <body>
33 </body>
34 </html>