test6.js

来自「《征服Ajax》原书的例题源码」· JavaScript 代码 · 共 29 行

JS
29
字号
function test() {
}

test.prototype = {
	p1 : "p1",
	p2 : "p2",
	f1 : function() {
		alert("f1");
	},
	f2 : function() {
		alert(this.p2);
	}
}

function test2() {
}

for (p in test.prototype) {
	test2.prototype[p] = test.prototype[p];
}
test2.prototype.newMethod = function() {
	alert("newMethod");
}



var t = new test2();
t.f2();
t.newMethod();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?