2013年3月2日

javascript 之apply和call

摘要: <script type="text/javascript"> //定义一个动物类 function ainimal(hight,weight) { this.hight = hight; this.weight = weight; } //定义一个狗类 function dog(hight, weight, name) { ainimal.apply(this, arguments); this.name = name; } //创建一个狗对象 var dog1 = new dog(30, 21, "大黄"); //测试 alert(&qu 阅读全文

posted @ 2013-03-02 20:25 唐山张 阅读(92) 评论(0) 推荐(0)

javascript面向对象之继承

摘要: <script language="JavaScript" type="text/javascript"> <!-- //定义extend方法 Object.extend = function (destination, source) { for (property in source) { destination[property] = source[property]; } return destination; } Object.prototype.extend = function (object) { return Obje 阅读全文

posted @ 2013-03-02 19:57 唐山张 阅读(82) 评论(0) 推荐(0)

javascript面向对象之参数扩展(仿jquery extend)

摘要: <script> Object.prototype.extend = function (para) { for (var key1 in this) { para[key1] = this[key1]; } return para; } function afun(para) { para=para.extend( {name:"li"} ); alert(para.name); } afun({name:"zhang"}); </script> 阅读全文

posted @ 2013-03-02 19:15 唐山张 阅读(114) 评论(0) 推荐(0)

导航