e 1 yıl önce
ebeveyn
işleme
d279575894

+ 57 - 0
JS初级/JS基础/4.运算符.html

@@ -0,0 +1,57 @@
+<!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>
+        var a = 1;
+        var b = 2;
+        var c = 10;
+        var d = 5;
+
+        // console.log(a+b);//3
+        // console.log(c-b);//8
+        // console.log(a*b);//2
+        // console.log(b/a);//2
+        // console.log(d % c); // 取低段位的值
+        // console.log(b % c);
+        // console.log(a % c);
+        // console.log(c % c);
+
+        // console.log(a + '2'); // 加法运算中 number + string 拼接
+        // console.log(a + c); // 11
+        // console.log('3' + '12'); // 加法运算中 string + string 拼接
+        // console.log(d + true);// 6 加法运算中 true = 1;false = 0; 
+        // console.log(b + null); // 2
+        // console.log(a + undefined); // NaN 非法数字
+
+        // console.log(c-b); // 8
+        // console.log(c - '4'); // 在减法运算中 string 与 number 执行运算规则
+        // console.log(c - 'hahahaha'); // NaN
+        // console.log(c - '哈哈哈');// NaN
+
+        // console.log(c - true); // 9 
+        // console.log(c - null);// 10
+        // console.log(c - undefined); // NaN
+
+        console.log(c * 2); //20
+        console.log(c * '2'); //在乘法运算中 string 与 number 执行运算规则
+        console.log(c * false);// 0
+        console.log(c * null); // 0
+        console.log(c * undefined)// NaN
+
+
+        console.log(c / 2);//5
+        console.log(c / '5'); //2 在除法运算中 string 与 number 执行运算规则
+        console.log(c / true); //10
+        console.log(c / false) //Infinity
+        console.log(c / null); //Infinity
+        console.log(c / undefined); // NaN
+
+    </script>
+</body>
+</html>

+ 36 - 0
JS初级/JS基础/5.运算1.html

@@ -0,0 +1,36 @@
+<!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>
+        var a = 5;
+        var b;
+
+        // 1.a++ 先赋值 后自增
+        b = a++;
+        console.log(a,'a'); // 6
+        console.log(b,'b'); // 5
+
+        // 2.++a 先自增 在赋值
+        b = ++a;
+        console.log(a,'a'); //7
+        console.log(b,'b'); //7
+
+        // 3.--a 先自减 在赋值
+        b = --a;
+        console.log(a,'a'); //6 
+        console.log(b,'b'); //6
+
+        // 4.a-- 先赋值 在自减
+        b = a--;
+        console.log(a,'a'); // 5
+        console.log(b,'b'); // 6 
+
+
+    </script>
+</body>
+</html>

+ 46 - 0
JS初级/JS基础/6.运算2.html

@@ -0,0 +1,46 @@
+<!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(2<3 || 5<4); // true 
+        console.log(2>3 || 5<4); // false
+
+
+        console.log(6>4 && 7<3);// false
+        console.log(6>4 && 7>3);// true
+
+        console.log(!true); // false
+        console.log(!0); // true
+        console.log( 5 != 2); // true
+
+        if(false == 0) {
+            console.log("♥相等")
+        } else {
+            console.log("♥不相等")
+        }
+
+     </script>
+     <!-- 特殊符号 
+            &nbsp; 半格
+            &lt;   小于
+            &gt;   大于
+            &reg   商标
+    -->
+    这是&nbsp;一段&lt;文字&gt;&reg;
+</body>
+</html>

+ 18 - 0
JS初级/JS基础/7.三元运算符.html

@@ -0,0 +1,18 @@
+<!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>
+        var a = 10;
+        console.log(a < 5 ? '大于' : '小于');
+     </script>
+</body>
+</html>

+ 30 - 0
JS初级/JS基础/8.语句.html

@@ -0,0 +1,30 @@
+<!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>
+        // {
+        //     代码块
+        // }
+      // 全局
+      var a = 6;
+      // 局部
+      function fn1() {
+        var c = 1;
+        console.log(c, "c");
+        console.log(a, "a");
+      }
+
+      fn1();
+      console.log(a, "a1");
+      console.log(c, "c1");
+    </script>
+  </body>
+</html>