💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
**JS类继承** ~~~ function people(){ var $this = this; $this.old = "老人"; $this.yang="青年"; $this.number = function(){ return $this.old; } } people.prototype.boy ="男孩"; function student(name,age) { var $p_this = this; $p_this.nameS = name; $p_this.age = age; $p_this.number = function(){ return getName(); } function getName(){ return $p_this.nameS; } function getAge(){ return $p_this.age; } } student.prototype.sex="男"; student.prototype.number = function(){ console.log("20170101"); } var stu1 = new student("小马",21); var stu2 = new student("小明",30); console.log(stu1.number()); function extend(student, people) { var F = function(){}; F.prototype = people.prototype; student.prototype = new F(); student.prototype.constructor = student; student.uber = people.prototype; // student.super = people.prototype; } extend(student, people); var stu1 = new student("小马",21); console.log(stu1.number()); console.log(stu1.boy); ~~~