What is meant by 'use strict' string costs in almond.js line 6?
A Google returns no information on the issue the author seems to be implying.
Strict Mode. Strict Mode(“use strict”) helps identify common issues (or “bad” parts) and also helps with “securing” JavaScript. In ES5, the Strict Mode is optional but in ES6, it's needed for many ES6 features.
The "use strict" directive was new in ECMAScript version 5. It is not a statement, but a literal expression, ignored by earlier versions of JavaScript. The purpose of "use strict" is to indicate that the code should be executed in "strict mode". With strict mode, you can not, for example, use undeclared variables.
Strict mode for modules The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Notice however that the main new ES6 features actually do imply strict mode, so yes it is on by default in modern code (which uses ES6 module syntax).
And the answer is apparently:
It is extra bytes to deliver the 'use strict' string in the source, and this is trying to be a small library. So, just a way to reduce file size by a little bit.
Which is a pretty silly "cost". It's 13 bytes before compression -- that's insignificant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With