12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <!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+b) // 3
- // console.log(a-b) //-1
- // console.log(a*b-c)//not defined
- // console.log(c)// not defined
- // var c;//undefined
- // console.log(a*b-c) //NaN 运算不下去
- // var d = a*7 + b;
- // console.log(d)//9
- // var a = 1;//number
- // var b = '456';//string
- // console.log(a+b)// 加法 当两种变量数据类型不统一的时候 一个为number 一个为string 默认进行拼接
- // var c = '哈哈哈哈哈'
- // console.log(b+c)//string 类型相加 默认进行拼接
- // var a = 1;
- // var b = true;
- // console.log(a+b)// number + boolean boolean转化为number 类型 true = 1 fasle = 0
- // var c = 'xxx'
- // console.log(c+b)//string + boolean 进行拼接
- // var a = 666;
- // var b = '123';
- // console.log(a-b)//string 参加减法运算 会把里面的内容转化为number类型 进行运算
- // var c = 'hahahha777'
- // console.log(a-c)//NaN 如果碰到非全数字的string 无法转化 无法参与计算
- // var d = false;
- // console.log(a-d)//boolean类型 参与减法运算 转化为number true = 1 false = 0
-
- // var a = 666;
- // ++a;
- // console.log(a)//667
- // a++;
- // console.log(a)//668
- // --a;
- // console.log(a)//667
- // var c = 777
- // // console.log(c++)//先输出 后++ 输出之后 c = 778
- // // console.log(++c)//先++ 后输出 c = 779
- // c++;// 输出 然后++ c = 778
- // console.log(c)
- </script>
- </body>
- </html>
|