2013年5月18日

javascript模拟c#类

摘要: Function.prototype.method = function (method, fn) { this.prototype[method] = fn }; function regClass(opt) { for (var x in opt) { if (typeof (opt[x]) != "function") { this[x] = opt[x]; } regClass.method("get" + x, function () { return opt[x]; }) regClass.method("set" + x 阅读全文

posted @ 2013-05-18 17:28 Thomas Guan 阅读(130) 评论(0) 推荐(0)

javascript编程的风格

摘要: 1.面向过程式风格...(回想起学校的时候老师问我,你真的懂面向对象吗?)function a(){..};function b(){..};2.var a=function(){...};a.prototype.show=function(){..};a.prototype.print=function(){...};3.var a=function(){..};a.prototype={show:function(){..},print:function(){}};4.Function.prototype.method=function(method,fn){ this.prototyp. 阅读全文

posted @ 2013-05-18 16:52 Thomas Guan 阅读(103) 评论(0) 推荐(0)

2012年12月14日

jquery 对象copy

摘要: js的对象赋值都属于对象的引用,我们对赋值后的对象改变属性的时候,发现父对象的属性也跟着变了,因为是引用类型的缘故,改的都是父类的对象;js对象继承也是一样的,没有效果;用jquery 来解决这个问题吧:<script type="text/javascript"> $(function () { var s = { a: "123", b: "345" }; var b = jQuery.extend(true, {}, s); b.b = "123sss"; alert(... 阅读全文

posted @ 2012-12-14 10:07 Thomas Guan 阅读(216) 评论(0) 推荐(0)

导航