// I am trying to make a clone of String's replace function
// and then re-define the replace function (with a mind to
// call the original from the new one with some mods)
String.prototype.replaceOriginal = String.prototype.replace
String.prototype.replace = {}
这下一行现在已经坏了 - 我该如何解决?如何用自定义函数替换javascript原型
"lorem ipsum".replaceOriginal(/(orem |um)/g,'')
它适用于我(在Firefox中)。如果你能解释“破碎”是什么意思,它可能会有所帮助。 – Pointy 2012-04-07 20:08:20
一致认为,它在Chrome中也可以正常工作:http://jsfiddle.net/4hPhG/ – 2012-04-07 20:09:38
我的代码中唯一可以看到的是错误的是第一条语句中缺少';'。 – 2012-04-07 20:10:33