摘要:
一、对象冒充1.function ClassA(name){ this.name = name;}ClassA.prototype.getName = function(){ return this.name;}function ClassB(name){ this.method1 = ClassA; this.method1(name); delete ClassB.prototype.method1;}2.callfunction ClassA(name){ this.name = name;}ClassA.prototype.getName = function(){ return... 阅读全文
posted @ 2014-03-07 21:49
小毅哥
阅读(154)
评论(0)
推荐(0)
摘要:
function StringBuffer(){ this._strings_ = new Array();}StringBuffer.prototype.append = function(str){ this._strings_.push(str);}StringBuffer.prototype.toString = function(){ this._strings_.join("");} 阅读全文
posted @ 2014-03-07 20:43
小毅哥
阅读(130)
评论(0)
推荐(0)
摘要:
一、工厂方法1.原始 var stu = new Object(); stu.name = "张三"; stu.age = 10; stu.getName = function(){ return this.name;}2.解决function createStudent(){ var stu = new Object(); stu.name = "张三"; stu.age = 10; stu.getName = function(){ return this.name;}return stu;}3.传参数function createStudent(n 阅读全文
posted @ 2014-03-07 20:37
小毅哥
阅读(132)
评论(0)
推荐(0)
浙公网安备 33010602011771号