<script>
function Person(name, age,sex) {
this.name= name;
this.age= age;
this.sex = sex;
}
Person.prototype.sex = "女";
let per = new Person("lily", 25, "男");
console.log(per.name);
console.log(per.age);
console.log(per.sex);
console.log("--------------------------------------------");
function People(name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
People.prototype.eat = function () {
console.log("人吃东西")
};
People.prototype.sleep = function () {
console.log("人在睡觉")
};
People.prototype.play = function () {
console.log("人在玩")
};
function Student(score) {
console.log("小明得了"+score+"分.....")
}
Student.prototype = new People("丽丽", 26, "女");
Student.prototype.study=function () {
console.log("学习很累很累的哦.");
};
Student.prototype.playgame = function () {
console.log("小明喜欢玩游戏")
};
let stu = new Student(29);
console.log(stu.sex);
console.log(stu.name);
console.log(stu.age);
stu.study();
stu.play();
stu.sleep();
stu.eat();
function Animal(name, weight) {
this.name = name;
this.weight = weight;
}
Animal.prototype.eat = function () {
console.log("天天吃东西,就是吃")
};
function Dog(color) {
this.color = color;
}
Dog.prototype = new Animal("哮天犬", "50kg");
Dog.prototype.bitePerson = function () {
console.log("哼 往往咬死你")
};
function ErHa(sex) {
this.sex = sex;
}
ErHa.prototype = new Dog("黑白色");
ErHa.prototype.playHost = function () {
console.log("能陪主人玩的很开心")
};
let erha = new ErHa("男");
console.log(erha.name,erha.weight,erha.color);
erha.playHost();
function Father(name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
Father.prototype.smoke = function () {
console.log("长辈喜欢抽烟")
};
function Son(name, age, sex, study) {
Father.call(this.name,age,sex);
this.study = study;
}
Son.prototype = new Father();
Son.prototype.eat = function () {
console.log("吃东西")
};
let st = new Son("lili" , "男" ,25 , "学习");
st.eat();
st.smoke();
</script>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~