Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What ECMAScript 5 'use strict' string costs exist?

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.

like image 337
Denis Hoctor Avatar asked Jul 07 '12 23:07

Denis Hoctor


People also ask

Does ES6 need use strict?

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.

What is use strict in ES6?

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.

Do JavaScript modules use strict mode?

Strict mode for modules The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.

Is ES6 strict by default?

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).


1 Answers

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.

like image 186
user149341 Avatar answered Oct 16 '22 14:10

user149341