When did all browsers start supporting the String.replace(regexp, replacement_function)?

允我心安 提交于 2019-11-30 17:41:52
guypursey

This answer is based on the comments to the question above (with special thanks to kangax, whose answer I will likely accept if he chooses to leave one!)

Whilst it's possible that I could have been reading "too many browsers" literally, it's also possible that String.replace() with a function as the argument was a problem in Safari 2.x (using JavaScriptCore) and in IEMac 5.x in the year 2005. Evidence of these problems in that time exists here, and with those particular versions of the aformentioned browsers here.

In fact the workaround mentioned by Gavin Kistner on the first of those pages is one whose performance may be better in some browsers than the functional replace method, as discussed here.

Nevertheless, performance aside, it seems (as I suspected) that a functional replace is acceptable in all browsers today.

Many thanks to all commenters on this question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!