Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: "use strict"
08-28-2011, 10:24 PM #1
- Join Date
- Nov 2002
- Thanked 1 Time in 1 Post
If I rework my scripts to work with "use strict", in theory, will they generally perform better, despite potential scripts growing in size? I hear there are some optimizations browsers will do and the changes may help. If so, would these optimizations be automatic or should I leave "use strict" in place to trigger them?
08-29-2011, 08:15 PM #2
- Join Date
- Jun 2007
- Thanked 586 Times in 567 Posts
stict mode is less powerful and easier to compile. if you have performance problems, use strict MAY help, but only in browsers than support it. On the other hand, JIT is so advanced these days performance is not nearly as important as it was when ecma5 was drafted just a few years ago...
in general, strict kills many potential performance-hampering features of js like with and eval. Those commands don't always hurt performance, but they certainly can, and avoiding them means you avoid the potential problems. So, just writing code that works with the strict sub-set of valid js is likely just as good as formally declaring strict mode.
Strict does make it easier to maintain that discipline because it throws errors when you break the guidelines. but i don't think the guidelines are all that relevant anyway, provided you know exactly what/how you are programming.