ruby的method_missing魔法在JavaScript中是否有类似等价物?答案是SpiderMonkey的__noSuchMethod__ 方法。演示如下(请firebug大神出马):
 
var obj = {};
obj.__noSuchMethod__ = function(/*String*/methodName,/*Array*/arrArguments){
    console.log(methodName, arrArguments);
}
obj.test(1,2);
// 打印出:"test", [1, 2]


总结:
  • ruby:method_missing
  • JavaScript(SpiderMonkey): __noSuchMethod__ (有可能会成为ECMAScript 3.1标准)
  • smalltalk:doesNotUnderstand
  • Objective-C:forward::
机器瞎学/数据掩埋/模式混淆/人工智障/深度遗忘/神经掉线/计算机幻觉/专注单身二十五年

posted on 2010-12-16 23:27  司徒正美  阅读(897)  评论(0编辑  收藏  举报

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2022-02-25
  • 2022-12-23
  • 2022-02-28
猜你喜欢
  • 2021-11-02
  • 2022-12-23
  • 2021-09-28
  • 2021-11-20
  • 2021-11-20
  • 2022-12-23
相关资源
相似解决方案