Linked Questions
118 questions linked to/from What does "use strict" do in JavaScript, and what is the reasoning behind it?
1178 votes
33 answers
520k views
Are there constants in JavaScript?
Is there a way to use constants in JavaScript? If not, what's the common practice for specifying variables that are used as constants?
597 votes
13 answers
123k views
Is JavaScript's "new" keyword considered harmful?
In another question, a user pointed out that the new keyword was dangerous to use and proposed a solution to object creation that did not use new. I didn't believe that was true, mostly because I've ...
648 votes
10 answers
127k views
What is the purpose of wrapping whole Javascript files in anonymous functions like “(function(){ … })()”?
I have been reading a lot of Javascript lately and I have been noticing that the whole file is wrapped like the following in the .js files to be imported. (function() { ... code ... })();...
148 votes
10 answers
80k views
What is "strict mode" and how is it used?
I've been looking over the JavaScript reference on the Mozilla Developer Network, and I came across something called "strict mode". I read it over and I'm having trouble understanding what ...
178 votes
2 answers
77k views
"Use Strict" needed in a TypeScript file?
I've seen posts regarding where to put the "use strict" line in a TypeScript code file. My question is, why have it at all? Since TypeScript is already a strongly typed language, what does "use ...
57 votes
8 answers
179k views
start/play embedded (iframe) youtube-video on click of an image
I'm trying to start playing an embedded youtube video by clicking an image. The idea is to have an image on top of a video, and when the image is clicked it fades out and starts playing the video. I'...
134 votes
1 answer
7k views
Why "use strict" improves performance 10x in this example?
Following the question Extending String.prototype performance I am really intrigued, because just adding "use strict" to a String.prototype method improved performance 10 times. The explanation by ...
63 votes
6 answers
7k views
Why doesn't JavaScript warn me when I use arr.lenght (misspelt) instead of arr.length in a loop? I also use strict mode
I spent hours just to find out that I misspelt the word .length as .lenght. It can run normally with no warning at all. Why...? I use 'use strict' and run on Node.js 10.13.0. Code: 'use strict';...
89 votes
3 answers
71k views
Can I disable ECMAscript strict mode for specific functions?
I don't find anything about my question here on MDC or the ECMAscript specifications. Probably somebody knows a more 'hacky' way to solve this. I'm calling "use strict" on every javascript file in my ...
37 votes
5 answers
20k views
When to NOT use "strict mode" in javascript?
I've found this post-What does "use strict" do in JavaScript, and what is the reasoning behind it? And what I'm understanding here is that I should use strict always. But I wonder, if it ...
43 votes
4 answers
9k views
In ECMAScript5, what's the scope of "use strict"?
What scope does the strict mode pragma have in ECMAScript5? "use strict"; I'd like to do this (mainly because JSLint doesn't complain about it): "use strict"; (function () { // my stuff here... }(...
21 votes
2 answers
4k views
Justifying Crockford claims
I have read Crockford's JavaScript: The Good Parts and have used his validator JSLint. I am sometimes left wondering the justification behind his recommendations. Below is a list of examples I want ...
19 votes
3 answers
5k views
Using node, why is code so much faster with "use strict"?
I never knew use strict to speed up runtime, however a simple use strict is making my benchmark substantially faster, and the slower one grossly slower (over twice as slow). What's going on? // // ...
18 votes
2 answers
11k views
Is it a good idea to always set --alwaysStrict to true in tsconfig.json?
Just curious whether there are any drawbacks to including: "compilerOptions": { "alwaysStrict": true, ... } Since it's false by default. Thoughts?
28 votes
1 answer
14k views
How can we listen for errors that do not trigger window.onerror?
https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers.onerror states: Note that some/many error events do not trigger window.onerror, you have to listen for them specifically. Could ...