# 类
构造方法指定constructor,不是类名,只能写一次 this在类里面表示对象,在外面表示window
代码语言:javascript复制<script>
class Person {
personName = "人类"
}
class User extends Person {
userId = 'admin';
userName = "管理员";
constructor() {
super()
}
run() {
console.log("run")
console.log(this.personName)
}
jump = function () {
console.log("jump")
}
eat = () => {
console.log('eat')
console.log('usrName: ' this.userName)
}
}
let u1 = new User()
u1.run();
u1.jump()
u1.eat()
let u2 = new User("zs", "张三")
u2.run();
u2.jump()
u2.eat()
const { userId, userName } = u1
console.log(userId)
</script>
# 解构
# 原型链
# 复制对象
代码语言:javascript复制let user = {name:"李雷", age: 20}
let u = {...user}
# Promise
Promise.resolve({}) 继续执行 reject是拒绝