Why is prototype function 40x slower than the default declared function?

前端 未结 2 1919
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 00:08

I\'ve played with jsperf.com and found that prototyped function is 40x slower than \"default\" declared function.

String.prototype.contains =

2条回答
  •  清酒与你
    2021-01-03 00:50

    Odds are very good that you're replacing a primitive function implemented in C/machine code with a JavaScript body in the monkey-patched version.

提交回复
热议问题