This commit is contained in:
Ilya Kantor 2019-03-07 11:01:31 +03:00
parent b310b741b0
commit 2a44419d92
3 changed files with 25 additions and 1 deletions

View file

@ -50,6 +50,12 @@ Open Preferences and go to the "Advanced" pane. There's a checkbox at the bottom
Now `key:Cmd+Opt+C` can toggle the console. Also, note that the new top menu item named "Develop" has appeared. It has many commands and options.
## Multi-line input
Usually, when we put a line of code into the console, and then press `ley:Enter`, it executes.
To insert multiple line, press `key:Shift+Enter`.
## Summary
- Developer tools allow us to see errors, run commands, examine variables, and much more.

View file

@ -47,6 +47,24 @@ There is no directive like `"no use strict"` that reverts the engine to old beha
Once we enter strict mode, there's no return.
```
## Browser console
For the future, when you use a browser console to test features, please note that it doesn't `use strict` by default.
Sometimes, when `use strict` makes a difference, you'll get incorrect results.
Even if we press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, it doesn't work. That's because of how the console executes the code internally.
The reliable way to ensure `use strict` would be to input the code into console like this:
```
(function() {
'use strict';
// ...your code...
})()
```
## Always "use strict"
We have yet to cover the differences between strict mode and the "default" mode.

View file

@ -41,7 +41,7 @@ let range = {
}
};
for(let value in range) {
for(let value of range) {
alert(value); // 1 then 2, then 3, then 4, then 5
}
```