Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
153
rated 0 times [  156] [ 3]  / answers: 1 / hits: 12590  / 10 Years ago, sun, february 16, 2014, 12:00:00

What are the additional benefits of use strict other than preventing bad coding? For instance, does it allow the script to run faster because the interpreter knows the code its optimized?


More From » use-strict

 Answers
7

There are a zillion benefits to strict mode, but since you asked specifically about performance, not just the good coding benefits, here's what MDN says about that:




Strict mode makes several changes to normal JavaScript semantics.
First, strict mode eliminates some JavaScript silent errors by
changing them to throw errors. Second, strict mode fixes mistakes that
make it difficult for JavaScript engines to perform optimizations:
strict mode code can sometimes be made to run faster than identical
code that's not strict mode. Third, strict mode prohibits some syntax
likely to be defined in future versions of ECMAScript.




So as you asked, according to the Firefox folks at MDN, strict mode code can sometimes run faster.



For general benefits of strict mode, see What does "use strict" do in JavaScript, and what is the reasoning behind it?


[#47674] Saturday, February 15, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
katia

Total Points: 570
Total Questions: 101
Total Answers: 85

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;