01 2015 档案
摘要:桥接模式(将抽象与其实现隔离开来,以便二者独立变化)function sendInfo(element){ var id=element.id; ajax("GET","info.json?id="+id,function(result){ //... }); ...
阅读全文
摘要:链式调用(function(){ function _$(els){ //... } _$.prototype={ each:function(fn){ for(var i=0,len=this.elements.length;i<...
阅读全文
摘要:单体模式:用来划分命名空间而组织一些方法和属性的对象,如果它能被实例化,只能被实例化一次;但对象不是单体var Singleton={ attr1:true; attr2:2, method1:function(){ ... }, method2:func...
阅读全文
摘要:子类引用父类function extend(subClass,superClass){ var F=function(){}; F.prototype=superClass.prototype; subClass.prototype=new F(); subClass.pro...
阅读全文
摘要:静态成员是直接通过类对象访问的var Book=(function(){ var numOfBooks=0; function checkIsbn(isbn){ ... } return function(newIsbn,newTitle,newAuthor){...
阅读全文
摘要:门户大开式对象var Book=function(isbn,title,author){ if (isbn==undefined) throw new Error("不合法"); this.isbn=isbn; this.title=title||'无标题'; this.au...
阅读全文
摘要:接口:利 固化一部分代码 弊 丧失js的灵活性在JavaScript中模仿接口/*interface Composite{ function add(child); function remove(child); function getChild(index);}interfac...
阅读全文
摘要:普通写法function startAnimation(){ ...}function stopAnimation(){ ...}对象类/*Anim class*/var Anim=function(){ ...};Anim.prototype.start = function()...
阅读全文
摘要:ctrl+p 查找文件 @进行符号查找ctrl+h 替换文件 选中字符以后多次按 ctrl+D 跳过则按 ctrl+Kctrl+shift+d 复制多行alt+f3 多选ctrl+shift+p 启动命令模式 输入#body跳转到body标签alt+.闭合标签ctrl+enter 另起一行全选 ct...
阅读全文