📄 test9.js
字号:
Object.extend = function(destination, source) {
for (property in source) {
destination[property] = source[property];
}
return destination;}
//定义一个抽象基类base,无构造函数
function base() {
}
base.prototype = {
initialize:function() {
this.oninit(); //调用了一个虚方法
}
}
function test() {
// 构造函数
}
test.prototype = Object.extend( {
prop : "prop",
oninit : function() {
alert(this.prop);
}
},
base.prototype
)
function test2() {
// 构造函数
}
test2.prototype = Object.extend( {
prop2 : "prop2",
oninit : function() {
alert(this.prop2);
}
},
base.prototype
)
var t = new test();
t.initialize(); // 输出"prop"
var t2 = new test2();
t2.initialize(); // 输出"prop2"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -