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
I stopped using strict mode because my code would never work the way I intended it to in strict mode.
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
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.
Can you make a video on Shadow dom and how can one manipulate CSS in shadow dom
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.
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).
Este man como le hace para ser tan inteligente
My gosh, JS used to be such a mess 🤣
Why don't you make some tutorials in angular.
The last one is scary ngl
javascrit is garbage imho
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.
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 🙂
Adding type=“module” in script tag will also use the defer attribute by default
“Are you in sloppy mode?” Depends who’s asking 😏
So strict mode is like you have more stricter teacher.
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.
awesome
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 😃👍👌
Why not use typescript like a normal person?
Or "use typescript"
FFS, just switch to typescript and don't look back.
You deserve dislike for this clickbait 😀
Or just use typescript 😅?
how to activate hidden typescript
i see a lot of tricky interview questions here
just use typescript omg
i might love JS, but brah, this is so bad
Someone at JS Central peeked at a PERL script … use strict; directive.
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.
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.
I love your videos, can´t stop waching them. Thanks for all this high quality videos.
learning the modern JS, strict mode has been effectively the default for me as I've always set my scripts as modules
You can’t use the “with” keyword in strict mode.
Can you get asked about strict mode in a junior dev interview?
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
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.
An excellent introduction to JavaScript Strict Mode. Thanks, Kyle
{2022-10-15}
Does strict mode check types just like typescript do?
Each video he posts justifies the name of his channel.
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!
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
That was good.
In school they teach us to "Use Strict" and do everything in Typescript.
Would got mad the day I would console.log(015) and see 13
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
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.