JavaScript Was So Bad They Had To Add A Second Mode To Fix It



JavaScript used to be the wild west when it came to hidden errors. So many unintuitive mistakes/errors were hidden which is why JavaScript introduced strict mode to clean up those weird interactions. Strict mode adds a bunch of different rules mostly around fixing potential bugs and surfacing them to the developer.

📚 Materials/References:

ES6 Modules Video: https://youtu.be/cRHQNNcYf6s
ES6 Modules Article: https://blog.webdevsimplified.com/2021-11/es6-modules

🌎 Find Me Here:

My Blog: https://blog.webdevsimplified.com
My Courses: https://courses.webdevsimplified.com
Patreon: https://www.patreon.com/WebDevSimplified
Twitter: https://twitter.com/DevSimplified
Discord: https://discord.gg/7StTjnR
GitHub: https://github.com/WebDevSimplified
CodePen: https://codepen.io/WebDevSimplified

⏱️ Timestamps:

00:00 – Introduction
00:27 – How to enter strict mode
02:30 – Reason #1 for strict mode
04:10 – Reason #2 for strict mode
05:56 – Reason #3 for strict mode
06:18 – Reason #4 for strict mode
07:19 – Reason #5 for strict mode
08:35 – Reason #6 for strict mode
09:47 – Reason #7 for strict mode
11:28 – Reason #8 for strict mode

#StrictMode #WDS #JavaScript

47 Comments

  1. Could you do a tutorial on await / promises / observables (more typescript content possibly?) I've found I've needed to rely on manually adding timeouts / waits using the waituntil npm package but was wondering if there was a better way to do this? Just more DB involved content would be nice I guess

  2. Hi Kyle. Hope you are doing well. A question from a professional perspective, if you dont mind. On a daily basis, at your workplace, what percentage of the time do you work in js, ts, react (each separate)? The reason i am asking, is that you keep doing these tutorials in/for js, but I(or many) try to switch to the react syntax and don't really write that much code in actual js anymore.

  3. Hi Web Dev Simplified, I truly love your videos, you are the reason why I originally got into web development. You've taught me so much in the past year and a half, and I was wondering if you could make a tutorial on implementing ads into your website. I've been trying for a while now but I can't seem to get it to work.

  4. Javascript as others 'moderns' languages like python, php is, and remain still bad regardless of every effort to improve it.
    (like typescript, flow, coffeescript etc).

  5. I've always wondered what is the purpose of "use strict" in javascript files, but never had the time to give it enough attention or to goggle what is its purpose. Now with this video everything is clear about "use strict" and I will absolutely use it in my future javascript projects. Thank you so much for this detailed explanation with usage examples.

  6. JavaScript: The Good Parts – is a good read. The behavior of 'this' is one part commented on in that book. Anyone have a timemachine to change this 🙂

  7. I've been using the strict mode since… well… 2012ish because of a recommendation from another developer. I've read an article online that argued that later ECMA version has it enabled by default. Now, I'm glad that I still put into my code and didn't listen to the article.

  8. After seeing this, I'm even more disappointed in that the ECMA guys had the balls to call this BS behavior "features" of the laguage, and treat their readers in a disgustingly condescending way for not thinking that JS is the masterpiece of design they think it is (it's a steaming piece of crap in its design, not to mention that it was left unattended and wasn't improved in over 10 years).

    From section "4.3.2 The Strict Variant of ECMAScript" of the official documentation:

    "The ECMAScript Language recognizes the possibility that some users of the language may wish to restrict their usage of some FEATURES available in the language. They might do so in the interests of security, to avoid what THEY CONSIDER to be error-prone FEATURES, to get enhanced error checking, or for other reasons of their choosing. In support of this possibility, ECMAScript defines a strict variant of the language."

    Awesome video Kyle! When I see one of your videos about a topic I already know, I always learn something new 😃👍👌

  9. Does strict mode log errors or does it also change the behavior of the web app? If it does change the behavior, I'd imagine there are frameworks for only keeping strict mode in the dev version.

  10. very usefull thing to know this morning. , but ppl please i have an issue , i am trying to use a button that was created and rendered because of an evenlistn like using a pop up button to redirect you BUT i can get it to work i tried the mutationoserver but didnt work , only thing that worked was setIntervals but that is not practical.

  11. man you are amazinggg. thats why i don't miss your video. I knew strict mode already. but that octal stuff just blew my mind. litterally i don't know how you get to know these stuff. thanks alot man. Now its my time to blewwww others mind by writing 015 xD

  12. I would prefer Javascript runtimes remove ASI, because, it's just annoying that people believe abusing this behavior is considered "good practice"
    Like saying "the legal limit of tread on a car tire is 1.6mm", so you should run it at that ALL THE TIME..
    Or, the legal speed limit on a road is 50mph, so I will travel that fast ALL THE TIME regardless of icy conditions or not.

  13. Your videos are always top notch and cover what I consider niche and advanced topics which is great. I recommend you to any friends who are learning javascript. Keep up the great work!

  14. Thank you so much for this explanation, I never paid attention to that use strict instruction. Now that I'm trying to teach some JS to new employees in the company I'm working in, it will help ensure they learn properly before we switch to TS

  15. Hi, can u pls explain how to get access to selectors that have same class names or id's so u could do onclick functions or add and delete classes or styles or data-attributes with JavaScript? Thanks

  16. Strict mode this has nothing to do with the security: first of all the code desides itself if it is writen in strict mode or not, secondly you can always access global object, there is even special globalThis word to do it. All strict mode featurtes are for catching possible bugs only.
    By the way, same argument names may be useful if you want to ignore these arguments like function (_, _, _, x) { return x }, but in strict mode you have to name them differently.

Leave a Reply

© 2023 53GB