test8.js

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

JS
33
字号
Object.extend = function(destination, source) {  for (property in source) {    destination[property] = source[property];  }  return destination;}


function test() {
}

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

function test2() {
}

test2.prototype = Object.extend (test.prototype, {
	newMethod : function () {
		alert("newMethod");
	}
});

var t = new test();
t.newMethod(); // 输出"newMethod"

⌨️ 快捷键说明

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