创建一个student类
function student(id,name,age) {
this.id=id;
this.name=name;
this.age=age;
this.study=function(){
console.log(this.id+""+this.name+'学习');
}
}
module.exports=student;
在创建一个teather类
var student=require('./student');
function teather(id,name,age){
student.apply(this, [id,name,age]);
this.teach=function(res){
console.log(this.name+"讲课");
}
}
module.exports=teather;
类的调用
var student=require('./class/student');
var stu=new student(1,'张三','20');
stu.study();
console.log('end');
var teather=require('./class/teather');
var te=new teather(2,'李四','10');
te.teach();