@@ -0,0 +1,21 @@
+// class 去声明类 首字母大写
+// 属性 方法
+// readonly 只读
+// static 相当于 变成了类方法
+class Person {
+ constructor() {
+ this.name = '图图';
+ this.age = 10;
+ }
+ static say() {
+ console.log("你好");
+}
+// 使用类
+// new 进行类的实例化
+let p = new Person();
+console.log(p);
+// p.name = '小新';
+console.log(p.name);
+// p.say();
+Person.say();
@@ -0,0 +1,26 @@
+// 构造函数
+// function Fn1() {}
+// 通过new实例化:new Fn1()
+// 函数
+// function fn1() {}
+// (function(){})() 立即执行函数
+// 箭头函数() => xx
+// 匿名函数
+// let xxx =function() {}
+// 构造函数:构造器(属性) 原型(方法)
+// function Fn1() {
+// }
+class Person1 {
+ // 构造器
+ constructor(x, y) {
+ console.log(this);
+ this.name = x;
+ this.age = y;
+ hello() {
+let p1 = new Person1('图图', 2);
+console.log(p1);
+p1.hello();
@@ -0,0 +1,11 @@
+<!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="./dist/2.构造函数和this.js"></script>
+</body>
+</html>
@@ -0,0 +1,20 @@
+ readonly name:string = '图图';
+ age:number = 10;
+ console.log("你好")
+
+console.log(p)
+console.log(p.name)
+Person.say()
@@ -0,0 +1,28 @@
+ name:string;age:number;
+ constructor(x:string,y:number) {
+ console.log(this)
+let p1 =new Person1('图图',2)
+console.log(p1)
@@ -0,0 +1,10 @@
+{
+ "include": [
+ "./src/**/*"
+ ],
+ "compilerOptions": {
+ "target": "es2015",
+ "module": "es2015",
+ "outDir": "./dist"