⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5.02 - namespacing.js

📁 JS设计模式源代码
💻 JS
字号:
/* Declared globally. */	function findProduct(id) {  ...}...// Later in your page, another programmer adds...var resetProduct = $('reset-product-button');var findProduct = $('find-product-button'); // The findProduct function just got                                            // overwritten./* Using a namespace. */var MyNamespace = {  findProduct: function(id) {	  ...  },  // Other methods can go here as well.}...// Later in your page, another programmer adds...var resetProduct = $('reset-product-button');var findProduct = $('find-product-button'); // Nothing was overwritten./* GiantCorp namespace. */var GiantCorp = {};GiantCorp.Common = {  // A singleton with common methods used by all objects and modules.};GiantCorp.ErrorCodes = {  // An object literal used to store data.};GiantCorp.PageHandler = {  // A singleton with page specific methods and attributes.};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -