12345678910111213141516171819202122232425262728 |
- "use strict";
- /**
- * 构造函数 => 函数
- 普通函数
- function fn1() {
- }
- 匿名函数
- let fn2 = function() {
- }
- 立即执行函数
- (function() {
- })()
- 箭头函数
- () => {}
- */
- class Person1 {
- constructor(name, age) {
- this.a = name;
- // age = b;
- this.age = age;
- }
- hello() {
- console.log("你好我好大家好", this);
- }
- }
- let p1 = new Person1('12', 20);
- console.log(p1, 'p1', this);
- p1.hello();
|