From the course: Mastering Web Developer Interview Code

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

What does "use strict" do?

What does "use strict" do?

- [Instructor] Some browsers allow for a feature that runs JavaScript in an alternate version called strict mode. Now, this makes it harder to make common programming mistakes. If you get this question in an interview chances are people want to make sure you are aware of the feature and what it does. So, let's take a look. Now, here's some very simple code, and I'm using this feature. And the way that you get started is by adding in the text use strict at the beginning of your code or inside a function, and it can be in single or double quotes. Now, the computer will now throw certain errors that it didn't before. So, for example, in the code above we're using a variable called scold without actually declaring it. So, to fix this we can just add the var keyword at the beginning of this, or if we don't want to use this strict version of JavaScript then this would work just fine. People who love strict mode…

Contents