JavaScript设计模式
ccyingfu
这个作者很懒,什么都没留下…
展开
-
接口设计
[code="html"] // Constructor.接口对象 var Interface = function(name, methods) { if(arguments.length != 2) { throw new Error("Interface constructor called with " + arguments.length ...原创 2010-06-11 20:07:41 · 80 阅读 · 0 评论 -
封装设计
[code="javascript"] var Book = (function() { // Private static attributes. var numOfBooks = 0; // Private static method. function checkIsbn(isbn) { ... } // Return the constructo...原创 2010-06-13 08:15:40 · 254 阅读 · 0 评论 -
继承设计
[code="javascript"] function extend(subClass, superClass){ var F = function(){}; F.prototype = superClass.prototype; subClass.prototype = new F(); subClass.prototy...原创 2010-06-13 08:20:34 · 170 阅读 · 0 评论 -
克隆设计
[code="javascript"] var book = { name : "Twilight", author : "Unkonw" } function myClone(object){ var f = function(){}; f.prototype = object; return new f; } var b ...原创 2010-06-13 15:49:07 · 105 阅读 · 0 评论 -
掺元类设计
[code="javascript"] var Mixin = function(){}; Mixin.prototype = { serialize : function(){ var output = []; for(key in this){ output.push(k...原创 2010-06-14 07:05:08 · 121 阅读 · 0 评论 -
自己的JavaScript库_建设中....哈哈
[code="javascript"] (function(){ function _$(els){ this.elements = []; for(var i = 0, len = els.length; i < len; i++){ var element = els[i]; if(typeof ...原创 2010-06-23 13:54:55 · 82 阅读 · 0 评论