e 3 тижнів тому
батько
коміт
24da5baff7

+ 1 - 0
3.js初级/js基础/1.js的引入.html

@@ -13,6 +13,7 @@
     <!-- 
         1.在html标签中添加script标签
         2.在script标签中的src属性里去引入js页面路径
+        console.log()打印
     -->
     <!-- <script>
         console.log("!1")

+ 60 - 0
3.js初级/js基础/14.对象.html

@@ -0,0 +1,60 @@
+<!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>
+        // 1.定义对象
+        var obj = {};
+        // 对象名.对象属性名 = 属性值
+        obj.name = '小明'
+        console.log(obj,'obj')
+        // 2.定义对象
+        var obj1 = new Object();
+        obj1.name = '小红'
+        obj1 = {
+            age: 19
+        }
+        console.log(obj1,'obj1')
+        var obj2 = {
+            name:"小黄"
+        }
+        var list = [
+            {
+                name: 'Lucy',
+                age:19,
+                address:'哈尔滨'
+            },
+            {
+                name: 'LiLi',
+                age:29,
+                address:'北京'
+            },
+            {
+                name: 'Tony',
+                age:25,
+                address:'天津'
+            }
+        ]
+        // 遍历数组
+        for(var i=0;i<list.length;i++) {
+            document.write('我叫' + list[i].name + '今年' + list[i].age + '了,我家住在'+list[i].address + "<br>")
+        }
+        // 驼峰命名法  第二个单词首字母大写 小驼峰
+        // NewObj 大驼峰
+        var newObj = {
+            name:'pig',
+            age:8,
+            sum:function(a,b) {
+                return console.log(a*b);
+            }
+        }
+        // newObj.sum(2,3)
+        newObj["sum"](4,6)
+        // console.log()
+    </script>
+</body>
+</html>

+ 38 - 0
3.js初级/js基础/15.数据类型判断.html

@@ -0,0 +1,38 @@
+<!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>
+    <!-- 
+        js数据类型
+            基本数据类型:
+                null undefined string boolean number
+            引用数据类型
+                object(object/array/function)
+    -->
+    <script>
+        let obj = {
+            name:'小明'
+        }
+        let arr = [1,2,3];
+        function fn1() {
+            return '你好'
+        }
+        // 1.typeof
+        console.log(typeof arr)
+        // 2.instanceof
+        console.log(fn1 instanceof Function)
+        // 3.Object.prototype.toString.call
+        console.log(Object.prototype.toString.call(fn1));
+        // 4.constructor
+        console.log(false.constructor === Boolean)
+        console.log(fn1.constructor === Boolean)
+        // console.log(null.constructor === Null)
+        // console.log(undefined.constructor === Undefined)
+    </script>
+
+</body>
+</html>

+ 57 - 62
3.js初级/js基础/4.运算符.html

@@ -1,68 +1,63 @@
 <!DOCTYPE html>
 <html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Document</title>
-</head>
-<body>
+  </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);//5 去低段位的值
-            // console.log(b % c);//2
-            // console.log(a % c);//1
-            // console.log(c % c);//0
-            // console.log(c % 3);//1
-
-            // console.log(a + '1');//11 加法运算 number + string 拼接
-            // console.log(a + c); // 11
-            // console.log('3'+'12');//312 string + string 拼接
-            // console.log(d + true); //6 加法运算中true=1 false=0
-            // console.log(b + null)//2
-            // console.log(b+undefined)//NaN 非法数字
-
-            // console.log(c-b);//8
-            // console.log(c-'4'); //6 减法 string number 执行正常的运算规则
-            // console.log(c-'hello');//NaN
-            // console.log(c-true);//9 减法运算中true=1 false=0
-            // console.log(c-null);//10
-            // console.log(c-undefined);//NaN
-
-            // console.log(c*b);//20
-            // console.log(c*'4'); //40 乘法 string number 执行正常的运算规则
-            // console.log(c*'hello');//NaN
-            // console.log(c*false);//0 乘法运算中true=1 false=0
-            // console.log(c*null);//0
-            // console.log(c*undefined);//NaN
-
-            
-            // console.log(c/b);//5
-            // console.log(c/'4'); //2.5 除法 string number 执行正常的运算规则
-            // console.log(c/'hello');//NaN
-            // console.log(c/false);//Infinity 除法运算中true=1 false=0
-            // console.log(c/null);//Infinity
-            // console.log(c/undefined);//NaN
-
-            console.log(c%b);//0
-            console.log(c%'2'); //2.5 取余 string number 执行正常的运算规则
-            console.log(c%'hello');//NaN
-            console.log(c%false);//NaN 取余运算中true=1 false=0
-            console.log(c%null);//NaN
-            console.log(c%undefined);//NaN
-
-
-
-        </script>
-
-</body>
-</html>
+    <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);//5 去低段位的值
+      // console.log(b % c);//2
+      // console.log(a % c);//1
+      // console.log(c % c);//0
+      // console.log(c % 3);//1
+
+      // console.log(a + '1');//11 加法运算 number + string 拼接
+      // console.log(a + c); // 11
+      // console.log('3'+'12');//312 string + string 拼接
+      // console.log(d + true); //6 加法运算中true=1 false=0
+      // console.log(b + null)//2
+      // console.log(b+undefined)//NaN 非法数字
+
+      // console.log(c-b);//8
+      // console.log(c-'4'); //6 减法 string number 执行正常的运算规则
+      // console.log(c-'hello');//NaN
+      // console.log(c-true);//9 减法运算中true=1 false=0
+      // console.log(c-null);//10
+      // console.log(c-undefined);//NaN
+
+      // console.log(c*b);//20
+      // console.log(c*'4'); //40 乘法 string number 执行正常的运算规则
+      // console.log(c*'hello');//NaN
+      // console.log(c*false);//0 乘法运算中true=1 false=0
+      // console.log(c*null);//0
+      // console.log(c*undefined);//NaN
+
+      // console.log(c/b);//5
+      // console.log(c/'4'); //2.5 除法 string number 执行正常的运算规则
+      // console.log(c/'hello');//NaN
+      // console.log(c/false);//Infinity 除法运算中true=1 false=0
+      // console.log(c/null);//Infinity
+      // console.log(c/undefined);//NaN
+
+      console.log(c % b); //0
+      console.log(c % "2"); //2.5 取余 string number 执行正常的运算规则
+      console.log(c % "hello"); //NaN
+      console.log(c % false); //NaN 取余运算中true=1 false=0
+      console.log(c % null); //NaN
+      console.log(c % undefined); //NaN
+    </script>
+  </body>
+</html>