如果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返回的是对象吗?
Function.method('new',function() {
var that=Object.beget(this.prototype);
var other=this.apply(that.arguments);
return (typeof other==='object'&&other)||other; //如果他返回的不是对象,就返回该新对象;
});
各位大侠能帮我 举一个例子说明other返回的是对象吗?
解决方案 »
- 异步请求后,IE8的一个奇怪的bug
- 页面提示声 就像论坛那种...
- Is there no JavaScript syntax, method that allows you to change the string?
- 求:js 日期插件 支持 ie6 ie7 ie8 ff
- 在table下能实现的功能,在div+css下却实现不了?不解?
- 正则
- IE和FireFox的脚本区别
- javascript创建的textarea在表单提交时不上传,而其它的input text可以
- jstl 遍历字符串并加以强调显示某个字
- printf("%.2f",i);这在javascript中如何处理想让i小数点2位输出
- 菜鸟请教下JS里的一些少见的语法意思
- 大家用的js集成开发环境常用的是什么啊,回着送分
有这个函数吗?
是不是自定义的
Function.prototype.method=function(name,func) {
this.prototype[name]=func;
return this;
}