//ES6实现继承
classPerson {
constructor(name, age) {
this.name= name;
this.age= age;
}
Show() {
return(this.name+' '+this.age);
}
}
classStudentextendsPerson {
constructor(name, age, School) {
super(name, age);
this.School= School;
}
Show() {
return(super.Show() +' '+this.School);
}
}
letme=newStudent("mochen","10","XD");
//ES5继承
functionjicheng(parent) {
functionF(){};
F.prototype= parent;
return newF();
}
//Promise实例
functionf(par) {
return newPromise((resolve, reject) => {
//异步操作
if(true)//如果判断条件为true,即异步执行成功
{
resolve(参数);
}else{
reject(参数);
}
})
}
letmyPromise=newf(par);
myPromise(par)
.then(()=> {})//此处为异步成功时你要执行的函数
.catch(() => {})//此处为异步失败你要执行的函数