奇怪的问题:Prototype 中 bind 方法,高分求解!

wideroad 2006-11-30 11:25:45
prototype中给Function.prototype加了一个bind方法,然后我在页面中写了一个最简单的方法:
function test(){}
然后我写了下面这段:
alert(Function.prototype.bind);
alert(test.bind);

在firefox2.0下前一个alert总是显示bind的方法,这个正常,但是下一个alert有时也显示bind方法,有时却是"undefined"。

我这个页面中没有任何代码,因为是在使用过程中发现的这个问题,因此我做了一个最简单的页面进行测试,会出现这样的问题,有没有高手能给解释一下???
...全文
231 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wideroad 2006-12-01
  • 打赏
  • 举报
回复
问题终于解决了,原来是firefox2.0的一个bug:
http://charlee.itbdns.com/tech/archives/199.html
wideroad 2006-11-30
  • 打赏
  • 举报
回复
有问题,不会吧!连prototype的源码中用bind都是test.bind,没有见过(test).bind的用法,而且从理论上来讲,test是个Function对象,就可以直接写test.bind,而不需要在test上加上小括号!
mrshelly 2006-11-30
  • 打赏
  • 举报
回复
你的用法有问题.

下面的你参考一下.

<script type="text/javascript">
var test=new Object();
function d(){ return "abc";}
test.abc=(d).bind(test);
alert(test.abc());
</script>
wideroad 2006-11-30
  • 打赏
  • 举报
回复
没有人遇到过这种问题吗?
lantersen 2006-11-30
  • 打赏
  • 举报
回复
你可以参照下实例:
<script>
Function.prototype.bind = function () { return ('Method bind value!!');};
alert(Function.prototype.bind() );
function test()
{}
alert('here is your function tt = '+test.bind());
</script>

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧