博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年7月20日

摘要: 伪类//构造器调用模式var Mammal = function (name){ this.name = name;};Mammal.prototype.get_name = function(){ return this.name;};Mammal.prototype.says = function (){ return this.saying || '';};var Cat = function(name){ this.name = name; this.saying = 'meow';};Cat.prototype = new Mammal();Cat.p 阅读全文

posted @ 2011-07-20 17:43 ritazhou 阅读(290) 评论(0) 推荐(0) 编辑

摘要: 参数 arguments当一个函数被调用时候,会得到一个argments数组的参数。通过它函数可以访问所有它被调用时传递给他的参数列表,包括没有在函数定义时定义的多余参数。这个arguments不是真正的数组,只有一个length的属性,并且能够通过index遍历。返回 returnreturn语句用于返回。如果没有指定返回值,则返回undefined。如果函数用new方式来调用,且返回值不是对象,那么返回this(该新对象)。异常 Exceptionvar add = function (a, b){ if(typeof a != 'number' || typeof b ! 阅读全文

posted @ 2011-07-20 15:50 ritazhou 阅读(320) 评论(0) 推荐(0) 编辑