function extend(subClass,superClass){
var F = function(){};
F.prototype = superClass.prototype;
subClass.prototype = new F();
subClass.prototype.constructor = subClass;
}
function Person(name){
this.name = name;
}
Person.prototype.getName = function(){
return this.name;
}
function Author(name,books){
Person.call(this,name);
this.books = books;
}
Author.prototype.getBooks = function(){
return this.books;
}
extend(Author,Person);
var p = new Person("张三");
var a = new Author("刘畅");
console.log(p.getName());
console.log(a.getName());
extends in javascript
sun_weitao2024-09-16 11:53
相关推荐
微学AI2 小时前
一根针指向所有方向:挂谷猜想对 LLM Agent 技能-记忆架构的启示郭老二2 小时前
【前端】vue3:编译步骤豆瓣鸡2 小时前
算法日记 - Day3不在逃避q2 小时前
Trae/Vs Code/Cursor命令行无法跑npm命令夏殇之殁3 小时前
包中创建自定义列表项。 . 使用自定义列表项进行数据绑定 . 将天气预报数据保存到本地内存表,通过LiveBindings进行显示。 ...韭菜炒鸡肝天3 小时前
VTK开发笔记(一):VTK介绍,Qt..+VSx+VTK.编译The Chosen One9853 小时前
高进度算法模板速记(待完善)陈随易3 小时前
MoonBit抓包模块pcap,查看电脑的每一次联网通信Aaron - Wistron3 小时前
Web API C# (Furion版)带 单元测试新中地GIS开发老师4 小时前
WebGIS开发学生作品|低空航天管理与航线规划系统