03 2012 档案
面向对象分装-prototype
摘要:prototype可以把那些固定的属性和方法,直接定义在prototype身上var Cat = function(name,color){ this.name = name; this.color = color;}Cat.prototype = { type:"猫科", eat:function(){ alert("吃老鼠"); } }//生成实例var cat1 = new Cat("大毛","黄色");var cat2 = new Cat("八路","灰色"); al 阅读全文
posted @ 2012-03-08 10:10 刘卿 阅读(203) 评论(0) 推荐(0)
判断对象是否存在
摘要:建议使用===(判断类型和值是否全等),if(obj===null){var my={}} 阅读全文
posted @ 2012-03-07 18:31 刘卿 阅读(206) 评论(0) 推荐(0)
闭包是什么?
摘要:闭包是指可以读取其他函数内部局部变量的函数,并且让这些变量始终保持在内存中. 阅读全文
posted @ 2012-03-07 18:04 刘卿 阅读(228) 评论(0) 推荐(0)