Merge branch 'en' of https://github.com/iliakan/javascript-tutorial into en
This commit is contained in:
commit
686ae5247f
3 changed files with 9 additions and 9 deletions
|
@ -1,14 +1,14 @@
|
|||
# Developer console
|
||||
|
||||
A code is error-prone. You are quite likely to have errors... Oh what I'm talking? You are *absolutely* going to make errors, at least if you're a human, not a [robot](https://en.wikipedia.org/wiki/Bender_(Futurama)).
|
||||
A code is prone to errors. You are quite likely to have errors... Oh, what am I talking about? You are *absolutely* going to make errors, at least if you're a human, not a [robot](https://en.wikipedia.org/wiki/Bender_(Futurama)).
|
||||
|
||||
But in the browser, a user doesn't see the errors by default. So, if something goes wrong in the script, we won't see what's broken and can't fix it.
|
||||
|
||||
To see errors and get a lot of other useful information about scripts, browsers have embedded "developer tools".
|
||||
|
||||
Most often developers lean towards Chrome or Firefox for the development, because developer tools are best there. Other browsers also provide developer tools, sometimes with special features, but usually are in "catching-up" position. So most people have a "favorite" browser and switch to others if a problem is browser-specific.
|
||||
Most often developers lean towards Chrome or Firefox for the development, because those browsers have the best developer tools. Other browsers also provide developer tools, sometimes with special features, but are usually playing "catching-up" to Chrome or Firefox. So most people have a "favorite" browser and switch to others if a problem is browser-specific.
|
||||
|
||||
Developer tools are really powerful, there are many features. Here, for the start, we'll learn how to open them, look at errors and run JavaScript commands.
|
||||
Developer tools are really powerful, there are many features. To start, we'll learn how to open them, look at errors and run JavaScript commands.
|
||||
|
||||
[cut]
|
||||
|
||||
|
@ -26,7 +26,7 @@ It looks somewhat like this:
|
|||
|
||||

|
||||
|
||||
The exact look depends on your Chrome version. It changes from time to time, but should be similar.
|
||||
The exact look of developer tools depends on your version of Chrome. It changes from time to time, but should be similar.
|
||||
|
||||
- Here we can see the red-colored error message. In this case the script contains an unknown "lalala" command.
|
||||
- On the right, there is a clickable link to the source `bug.html:12` with the line number where the error has occured.
|
||||
|
|
|
@ -102,7 +102,7 @@ As the time goes, the program becomes more and more complex. It becomes necessar
|
|||
|
||||
Comments can be put into any place of the script. They don't affect the execution, because the engine simply ignores them.
|
||||
|
||||
**One-line comments start with the two slash characters `//`.**
|
||||
**One-line comments start with the two forward slash characters `//`.**
|
||||
|
||||
The rest of the line is a comment. It may occupy a full line of its own or follow a statement.
|
||||
|
||||
|
@ -114,7 +114,7 @@ alert('Hello');
|
|||
alert('World'); // This comment follows the statement
|
||||
```
|
||||
|
||||
**Multiline comments start with a slash and a star <code>"/*"</code> and end with a star and a slash <code>"*/"</code>.**
|
||||
**Multiline comments start with a forward slash and an asterisk <code>"/*"</code> and end with an asterisk and a forward slash <code>"*/"</code>.**
|
||||
|
||||
Like this:
|
||||
|
||||
|
@ -156,6 +156,6 @@ alert( 'World' );
|
|||
|
||||
Please, don't hesitate to comment your code.
|
||||
|
||||
Comments increase the overall code footprint, but that's not a problem at all. There are many tools which minify the code before publishing to production server. They remove comments, so they do not appear in the working scripts. So, the comments do not have any negative effects on production at all.
|
||||
Comments increase the overall code footprint, but that's not a problem at all. There are many tools which minify the code before publishing to production server. They remove comments, so comments do not appear in the working scripts. So, the comments do not have any negative effects on production at all.
|
||||
|
||||
Further in the tutorial there will be a chapter <info:coding-style> that also explains how to write better comments.
|
||||
Further in the tutorial, there will be a chapter <info:coding-style> that also explains how to write better comments.
|
||||
|
|
|
@ -396,7 +396,7 @@ A few examples:
|
|||
|
||||
```js run
|
||||
alert( Math.max(3, 5, -10, 0, 1) ); // 5
|
||||
alert( Math.min(1, 2 ); // 1
|
||||
alert( Math.min(1, 2) ); // 1
|
||||
```
|
||||
|
||||
`Math.pow(n, power)`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue