JS设计模式源代码

源代码在线查看: 5.05 - private methods with closures.js

软件大小: 80 K
上传用户: BEIJINGHUANYING
关键词: 设计模式 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				/* Singleton as an Object Literal. */								MyNamespace.Singleton = {};								/* Singleton with Private Members, step 1. */								MyNamespace.Singleton = (function() {				  return {};				})();								/* Singleton with Private Members, step 2. */								MyNamespace.Singleton = (function() {				  return { // Public members.				    publicAttribute1: true,				    publicAttribute2: 10,				    				    publicMethod1: function() {				      ...				    },				    publicMethod2: function(args) {				      ...				    }				  };				})();								/* Singleton with Private Members, step 3. */								MyNamespace.Singleton = (function() {				  // Private members.				  var privateAttribute1 = false;				  var privateAttribute2 = [1, 2, 3];				  				  function privateMethod1() {				    ...				  }				  function privateMethod2(args) {				    ...				  }								  return { // Public members.				    publicAttribute1: true,				    publicAttribute2: 10,				    				    publicMethod1: function() {				      ...				    },				    publicMethod2: function(args) {				      ...				    }				  };				})();							

相关资源