JavaScript

JavaScript Application Structure

V------>DOM, BOM, Event (template)

C------>Function (function)

M------>Data (constructor, this, prototype, singleton)

Ajax负责Client与Server的数据传输。

singleton是很重要的。

http://kb.cnblogs.com/page/97011/

 1,对象直接量实现最基本,最简单的单体

var Singleton = {
attr1 :
1,
attr2 :
'hello',
method1 :
function(){alert(this.attr2);},
method2 :
function(arg){}
}

  这种方式中,对象所有成员都通过Singleton加点号访问。所有成员是公开的,没有私有的。在执行到变量Singleton时,会加载(实例化)自身,即非惰性加载。
  此外method1用this访问单体的其它成员会存在一些风险,因为method1的上下文不是总是指向Singleton对象。
  比如当把method1作为事件监听器时,this可能指向的是dom元素,这时可能会提示undefined。

http://kb.cnblogs.com/page/97009/

http://www.cnblogs.com/snandy/

原文地址:https://www.cnblogs.com/daishuguang/p/3459594.html