e 5 månader sedan
förälder
incheckning
972e0ec055
3 ändrade filer med 105 tillägg och 2 borttagningar
  1. 0 2
      js/js基础/12.提示框.html
  2. 55 0
      js/js基础/16.判断数据类型方法.html
  3. 50 0
      js/js基础/17.demo.html

+ 0 - 2
js/js基础/12.提示框.html

@@ -15,8 +15,6 @@
        var a = prompt("提示的内容信息",20);
        console.log(a)
 
-    //  案例1:进入页面 输入月份 页面显示当前月份及月份的天数;
-    //  案例2:进入页面 输入年份 页面显示当前年月及平年/闰年;
     </script>
 </body>
 </html>

+ 55 - 0
js/js基础/16.判断数据类型方法.html

@@ -0,0 +1,55 @@
+<!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 arr = [1,2,3,4];
+        var obj = {
+            name:"Lucy",
+            age:10
+        }
+        var fn1 = function() {
+            console.log("你好")
+        }
+        // 1.typeof
+        console.log(typeof 1);//number
+        console.log(typeof "1"); //string
+        console.log(typeof true); //boolean
+        console.log(typeof undefined); //undefined
+        console.log(typeof null); //object
+        console.log(typeof arr);//object
+        console.log(typeof obj);//object
+        console.log(typeof fn1);//function
+
+
+        // 2.instanceof
+        console.log(obj instanceof Object);
+        console.log(arr instanceof Object);
+        console.log(fn1 instanceof Object);
+
+        // 3.Object.prototype.toString.call()
+        console.log(Object.prototype.toString.call(1));   
+        console.log(Object.prototype.toString.call("哈哈"));   
+        console.log(Object.prototype.toString.call(false));   
+        console.log(Object.prototype.toString.call(null));   
+        console.log(Object.prototype.toString.call(undefined));   
+        console.log(Object.prototype.toString.call(obj));   
+        console.log(Object.prototype.toString.call(arr));   
+        console.log(Object.prototype.toString.call(fn1));   
+        
+        // 4.constructor 构造器 无法校验null 和 undefined
+        console.log((1).constructor === Number);
+        console.log("哈哈".constructor === String);
+        console.log(false.constructor === Boolean);
+        // console.log(null.constructor === Object);
+        // console.log(undefined.constructor === undefined);
+        console.log(obj.constructor === Object);
+        console.log(arr.constructor === Object);
+        console.log(fn1.constructor === Object);
+    </script>
+</body>
+</html>

+ 50 - 0
js/js基础/17.demo.html

@@ -0,0 +1,50 @@
+<!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 month = prompt("请输入月份");
+    // // console.log(month);
+    // switch(month) {
+    //     case "1":
+    //     case "3":
+    //     case "5":
+    //     case "7":
+    //     case "8":
+    //     case "10":
+    //     case "12":
+    //         console.log(month + "月份有31天");
+    //         break;
+    //     case 2:
+    //         console.log(month + "月份有19天");
+    //         break;
+    //     case "4":
+    //     case "6":
+    //     case "9":
+    //     case "11":
+    //         console.log(month + "月份有30天");
+    //         break;
+    //     default:
+    //         console.log("请输入正确的月份");
+    //         break;
+    // }
+    //  案例2:进入页面 输入年份 页面显示当前年月及平年/闰年;
+    var year  = prompt("请输入年份");
+    console.log(year);
+    if(year % 400 == 0 || year % 4 == 0 && year % 100 != 0) {
+        alert(year + "年是闰年");
+    } else {
+        alert(year + "年是平年");
+    }
+
+    // 案例三:进入页面 输入三角形的宽高 弹出三角形的面积 函数
+    </script>
+    
+</body>
+</html>