|
@@ -1,3 +1,4 @@
|
|
|
+"use strict";
|
|
|
/**
|
|
|
* 构造函数 => 函数
|
|
|
普通函数
|
|
@@ -9,18 +10,19 @@
|
|
|
立即执行函数
|
|
|
(function() {
|
|
|
})()
|
|
|
+ 箭头函数
|
|
|
+ () => {}
|
|
|
*/
|
|
|
-var Person1 = /** @class */ (function () {
|
|
|
- function Person1(name, age) {
|
|
|
- this.name = name;
|
|
|
+class Person1 {
|
|
|
+ constructor(name, age) {
|
|
|
+ this.a = name;
|
|
|
// age = b;
|
|
|
this.age = age;
|
|
|
}
|
|
|
- Person1.prototype.hello = function () {
|
|
|
+ hello() {
|
|
|
console.log("你好我好大家好", this);
|
|
|
- };
|
|
|
- return Person1;
|
|
|
-}());
|
|
|
-var p1 = new Person1("孙悟空", 20);
|
|
|
+ }
|
|
|
+}
|
|
|
+let p1 = new Person1('12', 20);
|
|
|
console.log(p1, 'p1', this);
|
|
|
p1.hello();
|