Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ca1ef0d
FIX: change ; to ,
leviding Oct 18, 2020
649539e
FIX: delete extra space
leviding Oct 18, 2020
4131b29
FIX: delete extra space
leviding Oct 19, 2020
030decc
Update article.md
iliakan Oct 20, 2020
9d4a69d
Update article.md
iliakan Oct 20, 2020
c634301
Update article.md
iliakan Oct 20, 2020
e74295c
Update article.md
iliakan Oct 20, 2020
959dc23
Update article.md
iliakan Oct 20, 2020
7487ce9
Update article.md
iliakan Oct 20, 2020
c69ca0d
Update article.md
iliakan Oct 20, 2020
44a17a3
Update article.md
iliakan Oct 20, 2020
d4120a0
Update article.md
iliakan Oct 20, 2020
fca113b
Update article.md
iliakan Oct 20, 2020
d961910
Update article.md
iliakan Oct 20, 2020
9ad8f66
Update article.md
iliakan Oct 20, 2020
e92bbb1
Update article.md
iliakan Oct 20, 2020
1197b01
Update article.md
iliakan Oct 20, 2020
614c5ff
Update article.md
iliakan Oct 20, 2020
6393a9f
Update article.md
iliakan Oct 20, 2020
a502398
Update article.md
iliakan Oct 20, 2020
24ff585
Update article.md
iliakan Oct 20, 2020
971a32e
Update article.md
iliakan Oct 20, 2020
7d05ada
Mention HTML attribute events in the summary
aruku Oct 19, 2020
ad3a7cc
Fix typo (I think)
aruku Oct 19, 2020
9b2f866
Fix typo in 1.4.7 (optional chaining)
vsemozhetbyt Oct 20, 2020
b0c60e3
Remove possibly outdated comment
vsemozhetbyt Oct 20, 2020
ae72328
Merge pull request #2222 from vsemozhetbyt/patch-11
iliakan Oct 20, 2020
4a75ea4
Mention function declaration in 1.6.5 (global object)
vsemozhetbyt Oct 21, 2020
e8455bc
Fix a typo in 1.6.6 (function object, NFE)
vsemozhetbyt Oct 21, 2020
518daec
Fix possible typo in 1.6.7 ("new Function" syntax)
vsemozhetbyt Oct 22, 2020
ad49592
Fix typos, specify link in 1.6.8 (Scheduling)
vsemozhetbyt Oct 22, 2020
c8edd84
Merge pull request #2213 from leviding/patch-28
iliakan Oct 22, 2020
3897d24
Merge pull request #2214 from leviding/patch-29
iliakan Oct 22, 2020
a10d94d
Merge pull request #2218 from aruku/aruku-patch-1
iliakan Oct 22, 2020
bd0fbbe
Merge pull request #2219 from vsemozhetbyt/patch-9
iliakan Oct 22, 2020
7ddddd2
Merge pull request #2224 from vsemozhetbyt/patch-11
iliakan Oct 22, 2020
decb6a2
Merge pull request #2226 from vsemozhetbyt/patch-12
iliakan Oct 22, 2020
44252ad
Merge pull request #2228 from vsemozhetbyt/patch-13
iliakan Oct 22, 2020
2d5be7b
Merge pull request #2229 from vsemozhetbyt/patch-14
iliakan Oct 22, 2020
4b8d987
merging all conflicts
iliakan Oct 26, 2020
cd2ec2f
Resolve conflicts/Update translation.
odsantos Oct 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 1-js/06-advanced-functions/04-var/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ In all the above cases we declare a Function Expression and run it immediately.

There are two main differences of `var`:

1. `var` variables have no block scope; their visibility is scoped to current function, or global, if declared outside function.
1. `var` variables have no block scope, their visibility is scoped to current function, or global, if declared outside function.
2. `var` declarations are processed at function start (script start for globals).

There's one more very minor difference related to the global object, that we'll cover in the next chapter.
Expand Down
4 changes: 3 additions & 1 deletion 1-js/06-advanced-functions/05-global-object/article.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Objeto global

O objeto global fornece variáveis e funções que estão disponíveis em qualquer lugar. Em sua maioria, aqueles que são incorporados ao idioma ou ao ambiente.
O objeto global fornece variáveis e funções que estão disponíveis em qualquer lugar. Na sua maioria, aquelas que são incorporadas ao idioma ou ao ambiente.

No navegador ele é chamado de `window`, no Node.js é `global`, em outros ambientes pode ter outro nome.

Expand All @@ -25,6 +25,8 @@ var gVar = 5;
alert(window.gVar); // 5 (se torna uma propriedade do objeto global)
```

O mesmo efeito têm declarações de função (instruções com a palavra-chave `function` no fluxo principal do código, não expressões de função).

Por favor, não confie nisso! Esse comportamento existe por motivos de compatibilidade. Scripts modernos usam [JavaScript modules](info:modules) onde tal coisa não acontece.

Se usássemos `let`, isso não aconteceria:
Expand Down
2 changes: 1 addition & 1 deletion 1-js/06-advanced-functions/06-function-object/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ If the function is declared as a Function Expression (not in the main code flow)

Also, functions may carry additional properties. Many well-known JavaScript libraries make great use of this feature.

They create a "main" function and attach many other "helper" functions to it. For instance, the [jQuery](https://jquery.com) library creates a function named `$`. The [lodash](https://lodash.com) library creates a function `_`, and then adds `_.clone`, `_.keyBy` and other properties to it (see the [docs](https://lodash.com/docs) when you want learn more about them). Actually, they do it to lessen their pollution of the global space, so that a single library gives only one global variable. That reduces the possibility of naming conflicts.
They create a "main" function and attach many other "helper" functions to it. For instance, the [jQuery](https://jquery.com) library creates a function named `$`. The [lodash](https://lodash.com) library creates a function `_`, and then adds `_.clone`, `_.keyBy` and other properties to it (see the [docs](https://lodash.com/docs) when you want to learn more about them). Actually, they do it to lessen their pollution of the global space, so that a single library gives only one global variable. That reduces the possibility of naming conflicts.


So, a function can do a useful job by itself and also carry a bunch of other functionality in properties.
2 changes: 1 addition & 1 deletion 1-js/06-advanced-functions/07-new-function/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Perhaps we want it to be able to access outer local variables?

The problem is that before JavaScript is published to production, it's compressed using a *minifier* -- a special program that shrinks code by removing extra comments, spaces and -- what's important, renames local variables into shorter ones.

For instance, if a function has `let userName`, minifier replaces it `let a` (or another letter if this one is occupied), and does it everywhere. That's usually a safe thing to do, because the variable is local, nothing outside the function can access it. And inside the function, minifier replaces every mention of it. Minifiers are smart, they analyze the code structure, so they don't break anything. They're not just a dumb find-and-replace.
For instance, if a function has `let userName`, minifier replaces it with `let a` (or another letter if this one is occupied), and does it everywhere. That's usually a safe thing to do, because the variable is local, nothing outside the function can access it. And inside the function, minifier replaces every mention of it. Minifiers are smart, they analyze the code structure, so they don't break anything. They're not just a dumb find-and-replace.

But, if `new Function` could access outer variables, then it would be unable to find `userName`, since this is passed in as a string *after* the code is minified.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ setTimeout(() => { clearInterval(timerId); alert('stop'); }, 5000);
```smart header="Modal windows freeze time in Chrome/Opera/Safari"
In browsers IE and Firefox the internal timer continues "ticking" while showing `alert/confirm/prompt`, but in Chrome, Opera and Safari the internal timer becomes "frozen".

So if you run the code above and don't dismiss the `alert` window for some time, then in Firefox/IE next `alert` will be shown immediately as you do it (2 seconds passed from the previous invocation), and in Chrome/Opera/Safari -- after 2 more seconds (timer did not tick during the `alert`).
So if you run the code above and don't dismiss the `alert` window for some time, then the next `alert` will be shown immediately as you do it. The actual interval between alerts will be shorter than 2 seconds.
```

## Nested setTimeout
Expand Down Expand Up @@ -382,7 +382,7 @@ First timers run immediately (just as written in the spec), and then the delay c

That limitation comes from ancient times and many scripts rely on it, so it exists for historical reasons.

For server-side JavaScript, that limitation does not exist, and there exist other ways to schedule an immediate asynchronous job, like [process.nextTick](https://nodejs.org/api/process.html) and [setImmediate](https://nodejs.org/api/timers.html) for Node.js. So the notion is browser-specific only.
For server-side JavaScript, that limitation does not exist, and there exist other ways to schedule an immediate asynchronous job, like [setImmediate](https://nodejs.org/api/timers.html#timers_setimmediate_callback_args) for Node.js. So this note is browser-specific.
````

### Allowing the browser to render
Expand Down Expand Up @@ -447,7 +447,7 @@ Now the `<div>` shows increasing values of `i`.
- To cancel the execution, we should call `clearTimeout/clearInterval` with the value returned by `setTimeout/setInterval`.
- Nested `setTimeout` calls are a more flexible alternative to `setInterval`, allowing us to set the time *between* executions more precisely.
- Zero delay scheduling with `setTimeout(func, 0)` (the same as `setTimeout(func)`) is used to schedule the call "as soon as possible, but after the current script is complete".
- The browser limits the minimal delay for five or more nested call of `setTimeout` or for `setInterval` (after 5th call) to 4ms. That's for historical reasons.
- The browser limits the minimal delay for five or more nested calls of `setTimeout` or for `setInterval` (after 5th call) to 4ms. That's for historical reasons.

Please note that all scheduling methods do not *guarantee* the exact delay. We should not rely on that in the scheduled code.

Expand Down
4 changes: 2 additions & 2 deletions 1-js/08-prototypes/01-prototype-inheritance/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ alert(admin.fullName); // John Smith (*)
// setter triggers!
admin.fullName = "Alice Cooper"; // (**)

alert(admin.fullName); // Alice Cooper , state of admin modified
alert(user.fullName); // John Smith , state of user protected
alert(admin.fullName); // Alice Cooper, state of admin modified
alert(user.fullName); // John Smith, state of user protected
```

Here in the line `(*)` the property `admin.fullName` has a getter in the prototype `user`, so it is called. And in the line `(**)` the property has a setter in the prototype, so it is called.
Expand Down
2 changes: 1 addition & 1 deletion 2-ui/2-events/02-bubbling-and-capturing/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ The event handling process:

- Then the event moves down from the document root to `event.target`, calling handlers assigned with `addEventListener(..., true)` on the way (`true` is a shorthand for `{capture: true}`).
- Then handlers are called on the target element itself.
- Then the event bubbles up from `event.target` to the root, calling handlers assigned using `on<event>` and `addEventListener` without the 3rd argument or with the 3rd argument `false/{capture:false}`.
- Then the event bubbles up from `event.target` to the root, calling handlers assigned using `on<event>`, HTML attributes and `addEventListener` without the 3rd argument or with the 3rd argument `false/{capture:false}`.

Each handler can access `event` object properties:

Expand Down
2 changes: 1 addition & 1 deletion 2-ui/2-events/03-event-delegation/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Capturing and bubbling allow us to implement one of most powerful event handling

The idea is that if we have a lot of elements handled in a similar way, then instead of assigning a handler to each of them -- we put a single handler on their common ancestor.

In the handler we get `event.target`, see where the event actually happened and handle it.
In the handler we get `event.target` to see where the event actually happened and handle it.

Let's see an example -- the [Ba-Gua diagram](http://en.wikipedia.org/wiki/Ba_gua) reflecting the ancient Chinese philosophy.

Expand Down