zheng 6 天之前
父節點
當前提交
e4d013f971
共有 3 個文件被更改,包括 58 次插入0 次删除
  1. 5 0
      ts/2.类型/1.ts
  2. 13 0
      ts/2.类型/demo.html
  3. 40 0
      ts/2.类型/demo.js

+ 5 - 0
ts/2.类型/1.ts

@@ -0,0 +1,5 @@
+/**
+ * 基本数据类型:number string null undefined boolean
+ * 引用数据类型:object(对象 数组 函数)
+ * typeof instaceof Object.prototype.toString.call constructor
+ */

+ 13 - 0
ts/2.类型/demo.html

@@ -0,0 +1,13 @@
+<!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 src="./demo.js">
+
+    </script>
+</body>
+</html>

+ 40 - 0
ts/2.类型/demo.js

@@ -0,0 +1,40 @@
+// console.log(typeof '1');
+// console.log(typeof 12);
+// console.log(typeof false);
+var a;
+// console.log(typeof a);
+// console.log(typeof null); //object
+let b = {
+    name:"图图"
+}
+let c = [1,2,3]
+function fn1() {
+    return 12;
+}
+
+// console.log(typeof b);
+// console.log(typeof c);
+// console.log(typeof fn1);
+
+// console.log(b instanceof Object);
+// console.log(c instanceof Object);
+// console.log(fn1 instanceof Function);
+
+
+// console.log(Object.prototype.toString.call(1))
+// console.log(Object.prototype.toString.call('12'))
+// console.log(Object.prototype.toString.call(true))
+// console.log(Object.prototype.toString.call(a))
+// console.log(Object.prototype.toString.call(b))
+// console.log(Object.prototype.toString.call(c))
+// console.log(Object.prototype.toString.call(fn1))
+// console.log(Object.prototype.toString.call(null))
+
+console.log(false.constructor === String)
+console.log('12'.constructor === String)
+console.log((1).constructor === Number)
+console.log(b.constructor === Object)
+console.log(c.constructor === Array)
+console.log(fn1.constructor === Function)
+// console.log(a.constructor === undefined)
+// console.log(null.constructor === Null)