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
相关推荐
人道领域5 小时前
【黑马点评日记】社交平台用户关注功能全解析Feed流相关操作xiaoshuaishuai85 小时前
C# DeepSeek V4 与 V3对比vivo互联网技术5 小时前
下一代图片格式 AVIF 在 vivo 社区的落地实践咸鱼翻身更入味5 小时前
Vue创建一个简单的Agent聊天bluetata5 小时前
AI 浪潮与破局:TypeScript 生态实战,让 AI 为你所用shehuiyuelaiyuehao5 小时前
算法18,二分查找IT策士5 小时前
Python mcp研究:入门到精通布局呆星5 小时前
Vue Router 核心知识点梳理罗技1235 小时前
告别“兼容模式“:Easysearch 有了自己的官方 Python 客户端