Is strict mode more performant?

前端 未结 4 492
你的背包
你的背包 2020-11-30 02:50

Does executing javascript within a browser in \'strict mode\' make it more performant, in general? Do any of the major browsers do additional optimisation or use any other t

4条回答
  •  臣服心动
    2020-11-30 03:36

    Is strict mode intended, amongst its other goals, to allow browsers to introduce additional optimisations or other performance enhancements?

    Whether or not it was intended to do this, I'm not sure, although I think the answer is yes.

    But I can say with certainty that strict mode does provide these opportunities, and browsers will implement them -- regardless whether providing those opportunities was an intentional goal for the ECMA committee. However, I wouldn't expect all those opportunities to be taken immediately. In many cases the mantra is likely to be correctness first, performance later, because strict mode is not widely used right now. (I work on Mozilla's JavaScript engine and have implemented various parts of strict mode, and we're implementing it this way as a general rule -- although I could probably think of an exception or two if I tried.)

提交回复
热议问题