+ -
当前位置:首页 → 问答吧 → new运算符

new运算符

时间:2011-09-11

来源:互联网

如果new运算符是个方法而不是一个运算符-----《JS精萃》
Function.method('new',function() {
  var that=Object.beget(this.prototype);
  var other=this.apply(that.arguments);
  return (typeof other==='object'&&other)||other; //如果他返回的不是对象,就返回该新对象;
});
各位大侠能帮我 举一个例子说明other返回的是对象吗?

作者: shijuren   发布时间: 2011-09-11

Function.method
有这个函数吗?
是不是自定义的

作者: aspwebchh   发布时间: 2011-09-11

前面还有一个函数
Function.prototype.method=function(name,func) {
  this.prototype[name]=func;
  return this;
}

作者: shijuren   发布时间: 2011-09-11