12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // var a = 1;
- // var b = 2;
- // console.log(a*4+b-c) //NaN
- // console.log(c)// undefined
- // var c = a + b; //变量是可以参与运算的
- // alert(c)
- // var d = a * 2 + b ;
- // alert(d)
- // var a = 1; //number
- // var b = '456' // string
- // console.log(a+b) // 加法 当两种变量数据类型不统一 一个为number 一个为string 默认进行拼接
- // var c = '哈哈哈哈'
- // console.log(b+c)//string类型相加 默认拼接
- // var d = true
- // console.log(a+d) //2 number + boolean boolean 转为 number类型 当为true 值为1 false 值为0
- // console.log(c+d) //哈哈哈哈true
- // var h;
- // console.log(h+c)//碰到string 相加 都进行拼接
- // var a = 123;
- // var b = '456';
- // console.log(b-a)//string 参与减法运算 会把里面的内容转为number类型
- // var c = 'haha777'
- // console.log(c-a)//NaN 但是如果碰到非全数字的string 无法转化 那么无法参与计算
- // var d = false
- // console.log(a-d)//boolean类型 参与加法运算 转为number true为1 false为0
- // var a = 111;
- // a++;
- // console.log(a) //a++ 自增 每次+1
- // //a 112
- // a--;
- // console.log(a)
- // var a = 666;
- // ++a;
- // console.log(a)//667
- // a++;
- // console.log(a)/668
- // --a;
- // console.log(a)//667
- // console.log(a)
- // var c = a++;//先输出 后++
- // console.log(c)//667
- // console.log(++c)//668
- // console.log(a)//668
- var a = 5
- console.log(a++)//5 先输出 后++ a=6
- console.log(++a)//先++ 后输出 a=7
- </script>
- </body>
- </html>
|