Skip to content

Commit 4b8d987

Browse files
committed
merging all conflicts
2 parents d188c83 + 2d5be7b commit 4b8d987

File tree

8 files changed

+26
-8
lines changed

8 files changed

+26
-8
lines changed

1-js/06-advanced-functions/04-var/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ In all the above cases we declare a Function Expression and run it immediately.
264264

265265
There are two main differences of `var`:
266266

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

270270
There's one more very minor difference related to the global object, that we'll cover in the next chapter.

1-js/06-advanced-functions/05-global-object/article.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ O objeto global fornece variáveis e funções que estão disponíveis em qualqu
55

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

8+
<<<<<<< HEAD
89
Recentemente, `globalThis` foi adicionado à linguagem como um nome padrão para o objeto global, e que deve ser suportado em todos os ambientes. Ele é suportado em todos os principais navegadores.
10+
=======
11+
Recently, `globalThis` was added to the language, as a standardized name for a global object, that should be supported across all environments. It's supported in all major browsers.
12+
>>>>>>> 2d5be7b7307b0a4a85e872d229e0cebd2d8563b5
913
1014
Usamos `window` aqui, assumindo que nosso ambiente seja um navegador. Se o seu script puder ser executado em outros ambientes, é melhor utilizar o `globalThis`.
1115

@@ -25,7 +29,13 @@ var gVar = 5;
2529
alert(window.gVar); // 5 (se torna uma propriedade do objeto global)
2630
```
2731

32+
<<<<<<< HEAD
2833
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.
34+
=======
35+
The same effect have function declarations (statements with `function` keyword in the main code flow, not function expressions).
36+
37+
Please don't rely on that! This behavior exists for compatibility reasons. Modern scripts use [JavaScript modules](info:modules) where such thing doesn't happen.
38+
>>>>>>> 2d5be7b7307b0a4a85e872d229e0cebd2d8563b5
2939
3040
Se usássemos `let`, isso não aconteceria:
3141

1-js/06-advanced-functions/06-function-object/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ If the function is declared as a Function Expression (not in the main code flow)
347347

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

350-
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.
350+
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.
351351

352352

353353
So, a function can do a useful job by itself and also carry a bunch of other functionality in properties.

1-js/06-advanced-functions/07-new-function/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Perhaps we want it to be able to access outer local variables?
9191

9292
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.
9393

94-
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.
94+
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.
9595

9696
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.
9797

1-js/06-advanced-functions/08-settimeout-setinterval/article.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ setTimeout(() => { clearInterval(timerId); alert('stop'); }, 5000);
130130
```smart header="Modal windows freeze time in Chrome/Opera/Safari"
131131
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".
132132
133+
<<<<<<< HEAD
133134
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`).
135+
=======
136+
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.
137+
>>>>>>> 2d5be7b7307b0a4a85e872d229e0cebd2d8563b5
134138
```
135139

136140
## Nested setTimeout
@@ -382,7 +386,11 @@ First timers run immediately (just as written in the spec), and then the delay c
382386
383387
That limitation comes from ancient times and many scripts rely on it, so it exists for historical reasons.
384388
389+
<<<<<<< HEAD
385390
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.
391+
=======
392+
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.
393+
>>>>>>> 2d5be7b7307b0a4a85e872d229e0cebd2d8563b5
386394
````
387395

388396
### Allowing the browser to render
@@ -447,7 +455,7 @@ Now the `<div>` shows increasing values of `i`.
447455
- To cancel the execution, we should call `clearTimeout/clearInterval` with the value returned by `setTimeout/setInterval`.
448456
- Nested `setTimeout` calls are a more flexible alternative to `setInterval`, allowing us to set the time *between* executions more precisely.
449457
- 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".
450-
- 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.
458+
- 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.
451459

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

1-js/08-prototypes/01-prototype-inheritance/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ alert(admin.fullName); // John Smith (*)
199199
// setter triggers!
200200
admin.fullName = "Alice Cooper"; // (**)
201201

202-
alert(admin.fullName); // Alice Cooper , state of admin modified
203-
alert(user.fullName); // John Smith , state of user protected
202+
alert(admin.fullName); // Alice Cooper, state of admin modified
203+
alert(user.fullName); // John Smith, state of user protected
204204
```
205205

206206
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.

2-ui/2-events/02-bubbling-and-capturing/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ The event handling process:
197197
198198
- 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}`).
199199
- Then handlers are called on the target element itself.
200-
- 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}`.
200+
- 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}`.
201201
202202
Each handler can access `event` object properties:
203203

2-ui/2-events/03-event-delegation/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Capturing and bubbling allow us to implement one of most powerful event handling
55

66
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.
77

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

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

0 commit comments

Comments
 (0)