e 1 tahun lalu
induk
melakukan
adfa8b0574

+ 59 - 0
day8/html/5.运算符.html

@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>运算符</title>
+</head>
+<body>
+    <script>
+        var a = 1;
+        var b = 2;
+        var c = 10;
+        var d = 5;
+        console.log(a+b,'a+b')
+        console.log(c-d,'c-d')
+        console.log(a*b,'a*b')
+        console.log(a/b,'a/b')
+        // %取余
+        console.log(b%c,'b%c')
+
+        console.log(a + '23')//在加法运算中,number + string 这两种数据类型的时候 进行拼接
+        console.log(b + '56')//256
+        console.log('34'+'56')//在加法运算中,都是字符串时进行拼接
+        console.log('ab'+b)//ab2
+        console.log(true + c)//number时 true => 1(number)  11
+        console.log(true + '34')//string时 true34
+        console.log(true + false)//boolean时 true=>1 false=>0    1 
+        console.log(null + c)// 10
+        console.log(undefined + c)//NaN 非法数字 无法运算 
+
+        console.log(c-d)//5 在减法运算中 number类型时 正常的减法运算
+        console.log(c - '2')//8在减法运算中 number string(数字) 进行数据类型换算 可以进行减法运算
+        console.log(c - '哈哈哈')//NaN 
+        console.log(c - 'hahaha')//NaN
+
+        console.log(c - true)//9
+        console.log(c - null)//10
+        console.log(c - undefined)//NaN
+
+        console.log(c * '2')// 20
+        console.log(c * '哈哈哈')//NaN
+        console.log(c * 'hahaha')//NaN
+        console.log(c * d) // 50
+        console.log(c * false)// 0
+        console.log(c * null)// 0
+        console.log(c * undefined)//NaN
+
+
+        console.log(c / '2')//5
+        console.log(c / 'hahah')//NaN
+        console.log(c / false)//Infinity
+        console.log(c / true)//10
+        console.log(c / null)//Infinity
+        console.log(c / undefined)//NaN
+
+
+    </script>
+</body>
+</html>

+ 40 - 0
day8/html/6.运算.html

@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>运算</title>
+</head>
+<body>
+    <script>
+        var a = 5;
+        var b;
+        // a++ 先赋值 后自增
+        b = a++;
+        console.log(b,'b')
+        console.log(a,'a')
+
+        var d = 5;
+        var c;
+        // ++a 先自增 后赋值
+        c = ++d;
+        console.log(c,'c')
+        console.log(d,'d')
+
+
+        // a= 6 b=5
+        a = b--;
+        // b-- 先赋值 后自减
+        console.log(b,'b')
+        console.log(a,'a')
+
+        // a=5 b=4
+        b = --a
+        // --b 先自减 后赋值
+        console.log(b,'b')
+        console.log(a,'a')
+
+
+    </script>
+</body>
+</html>

+ 43 - 0
day8/html/7.运算.html

@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        // > < = >= <=
+        // 逻辑运算符
+        // || 或 只要其中一方是真 则为真 除非都不为真 才是假
+        // && 和 只有双方都为真 才为真;有一方假 则为假
+        // ! 非 去对方的反之;与等于号同时使用时=>不等于
+        console.log(5<2 || 5>3)//true
+        console.log(2<10 || 3>1)//true
+        console.log(2>4 || 1>3)//false
+
+        console.log(2>4 && 4<5)//false
+        console.log(2<4 && 3>5)// false
+        console.log(4>2 && 5>1)// true
+
+        console.log(!true)// false
+        console.log(!0)// true
+        console.log(5!=2)//true
+
+        console.log('abc'-"a")//NaN
+
+
+        // = 进行赋值 不进行判断
+        // == 进行判断不进行赋值 类型不同强制转换
+        // === 全等 进行判断 不会转换数据类型 
+        var a = 1;
+        var b = '1';
+        if(null === undefined) {
+            alert("♥等于")
+        } else {
+            alert("♥不等于")
+        }
+
+    </script>
+</body>
+</html>

+ 16 - 0
day8/html/8.三元运算符.html

@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>三元运算符</title>
+</head>
+<body>
+    <script>
+        // 三元运算符 三目运算符
+        var a = 10;
+        console.log(a<5?'大于':'小于')
+        // 判断条件语句 ? "条件为真时返回内容" : "条件不成立时返回的内容"
+    </script>
+</body>
+</html>