摘要: 用于存储和访问函数参数的参数对象公共属性:1. callee:Function 当前正在执行函数的引用。2. length:Number 参数数目。递归函数尽量采用arguments,防止函数名有变化,导致错误。function factorial(num){ if(num == 1) ... 阅读全文
posted @ 2014-12-05 13:40 lcw5945 阅读(151) 评论(0) 推荐(0) 编辑
摘要: var singleton = function(){ //私有 var priVar = 10; function priFun(){ return false; } //公有 return { publicProperty: tru... 阅读全文
posted @ 2014-12-05 10:58 lcw5945 阅读(81) 评论(0) 推荐(0) 编辑
摘要: function Person(age){ var name = "Lala"; //私有变量 this.age = age; //公有变量 this.getName = function(){ //公有函数 return name; }}var p1... 阅读全文
posted @ 2014-12-04 16:52 lcw5945 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 内存管理是很重要的一部分,系统分配给浏览器的内存空间很少,如果不能很好的管理内存很可能因为某个页面导致浏览器的崩溃。虽然js有垃圾回收机制,但是在程序中如果不用的对象,要及时释放引用等待gc回收js垃圾回收的机制1. 标记清除当变量进入环境时,将变量标记"进入环境",当变量离开环境时,标记为:"离开... 阅读全文
posted @ 2014-12-04 15:47 lcw5945 阅读(400) 评论(0) 推荐(0) 编辑
摘要: this 通常是指当前实例对象,每个函数在被调用时,会自动创建2个特殊变量,this和arguments ,他们只活动在函数内部,不会访问外部。var name = "glob this";var obj={ name : "obj this", getName : function()... 阅读全文
posted @ 2014-12-04 14:57 lcw5945 阅读(99) 评论(0) 推荐(0) 编辑
摘要: function createClose(){ var r = new Array(); for (var i = 0; i"); } return r;}// alert(createClose());var funs = createClose();document.wr... 阅读全文
posted @ 2014-12-04 14:34 lcw5945 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 编译参数加上:-defaults-css-url default.css然后建个default.css 文件放到src根目录 阅读全文
posted @ 2014-12-04 11:53 lcw5945 阅读(151) 评论(0) 推荐(0) 编辑
摘要: //对象克隆function object(o){function F(){}F.prototype = o;return new F();}//原型继承function inheritPrototype(subType,superType){var prototype = object(super... 阅读全文
posted @ 2014-12-04 11:50 lcw5945 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 此方式即可满足函数的复用,也可满足子类实例有各自的属性,也可传递参数。function SuperType(name){ this.name = name; //参数传递 this.colors = [1,2]; //子类实例共有基本值} SuperType.prototype.sayN... 阅读全文
posted @ 2014-12-04 11:48 lcw5945 阅读(151) 评论(0) 推荐(0) 编辑
摘要: function SuperType(){this.colors = [1,2,3];} function SubType(){//继承属性SuperType.call(this);} var in1 = new SubType();in1.colors.push(4);alert(in1.colo... 阅读全文
posted @ 2014-12-04 11:47 lcw5945 阅读(113) 评论(0) 推荐(0) 编辑