What does "use strict" do in JavaScript and why is it needed?
Hello everyone! I started learning JavaScript and noticed that in some code examples at the beginning of a file or function they write `'use strict';`. Honestly, I don't quite understand why this is needed and what it actually does.
I tried writing a simple script without this directive, and everything worked. For example, I accidentally created a variable without `let`, `const`, or `var`:
```javascript
function test() {
myVar = 10; // I forgot to write let
console.log(myVar);
}
test(); // Outputs 10
```
But if I add `'use strict';`:
```javascript
'use strict';
function test() {
myVar = 10; // Error!
console.log(myVar);
}
test(); // ReferenceError: myVar is not defined
```
Now the code throws an error. It seems like without `'use strict'` everything worked more simply, but I've heard that experienced developers