Dynamic vs Inline RegExp performance in JavaScript

后端 未结 3 1033
鱼传尺愫
鱼传尺愫 2020-12-25 11:03

I stumbled upon that performance test, saying that RegExps in JavaScript are not necessarily slow: http://jsperf.com/regexp-indexof-perf

There\'s one thing i didn\'t

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-25 11:15

    in the second case, the regular expression object is created during the parsing of the language, and in the first case, the RegExp class constructor has to parse an arbitrary string.

提交回复
热议问题