js 采用delete实现继承
来源:互联网 发布:2017我国网络发展现状 编辑:程序博客网 时间:2024/06/05 11:52
//采用对象冒充的方式实现js继承
function A(color) {
this.Acolor = color;
this.AshowColor = function() {
document.writeln("Acolor: " + this.Acolor);
}
}
function B(color, name) {
//将newMethod赋值A,调用A的构造函数
this.newMethod = A;
this.newMethod(color);
//然后删除对A的引用,这样以后不能调用他
delete this.newMethod;
this.Bname = name;
this.BshowName = function() {
document.writeln("Bname: " + this.Bname);
}
}
var objA = new A("red");
objA.AshowColor();
document.writeln("----------------");
var objB = new B("black", "demo");
objB.AshowColor();
objB.BshowName();
document.writeln("----------------");
- js 采用delete实现继承
- js 采用call实现继承
- js 采用apply实现继承
- js 采用prototype实现继承
- js继承如何实现继承?
- js中的继承实现
- js中的继承实现
- JS中的继承实现
- js中的继承实现
- js继承机制实现
- js如何实现继承
- JS继承的实现
- js实现继承机制
- js继承的实现
- js实现类继承
- js继承的实现
- js继承的实现
- js继承的实现
- C++中extern “C”含义深层探索
- kernel 启动过程之三, start_kernel()函数 概叙!init/main.c
- 26、从头学Android之多媒体--使用MediaRecorder录制音频
- windows2008服务器IIS7下php程序伪静态处理 猫叔
- webview js 与java代码交互问题(成员变量名 和方法名不能重名 啃爹啊)
- js 采用delete实现继承
- cocos2dx3.0 触摸事件
- 如何用Eclipse+tomcat部署一个网站
- 27、从头学Android之多媒体--使用VideoView播放视频
- XMPP资源绑定(Resource Binding)
- 截获输入法的文字
- 28、从头学Android之多媒体--使用MediaPlayer和SurfaceView播放视频
- 斐波那契
- (转)Linux下给mysql创建用户分配权限