Skip to content

Commit 8266f75

Browse files
committed
merging all conflicts
2 parents 9760284 + 039716d commit 8266f75

File tree

11 files changed

+56
-25
lines changed

11 files changed

+56
-25
lines changed

1-js/01-getting-started/1-intro/article.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,20 @@ Ferramentas modernas tornam a transpilação muito rápida e transparente, permi
106106

107107
Exemplos de tais linguagens:
108108

109+
<<<<<<< HEAD
109110
- [CoffeeScript](http://coffeescript.org/) é um "açúcar sintático" para JavaScript. Ele introduz uma sintaxe mais curta, permitindo-nos escrever um código mais claro e preciso. Normalmente, Ruby devs gostam dele.
110111
- [TypeScript](http://www.typescriptlang.org/) está concentrado em adicionar "estritos tipos de dados" para simplificar o desenvolvimento e suporte de sistemas complexos. É desenvolvido pela Microsoft.
111112
- [Flow](http://flow.org/) também adiciona tipos de dados, mas de uma forma diferente. Desenvolvido pela Facebook.
112113
- [Dart](https://www.dartlang.org/) é uma linguagem autônoma que tem seu próprio interpretador que roda em ambientes fora do navegador (como aplicativos móveis), mas também pode ser transpilada para JavaScript. Desenvolvido pela Google.
113114
- [Brython](https://brython.info/) é um transpilador de Python para JavaScript que permite escrever aplicativos em puro Python, sem JavaScript.
115+
=======
116+
- [CoffeeScript](http://coffeescript.org/) is a "syntactic sugar" for JavaScript. It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it.
117+
- [TypeScript](http://www.typescriptlang.org/) is concentrated on adding "strict data typing" to simplify the development and support of complex systems. It is developed by Microsoft.
118+
- [Flow](http://flow.org/) also adds data typing, but in a different way. Developed by Facebook.
119+
- [Dart](https://www.dartlang.org/) is a standalone language that has its own engine that runs in non-browser environments (like mobile apps), but also can be transpiled to JavaScript. Developed by Google.
120+
- [Brython](https://brython.info/) is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.
121+
- [Kotlin](https://kotlinlang.org/docs/js-overview.html) is a modern, concise and safe programming language that can target the browser or Node.
122+
>>>>>>> 039716de8a96f49b5fccd7aed5effff2e719dfe5
114123
115124
Há mais. Claro que, mesmo que usemos uma dessas linguagens transpiladas, também devemos saber JavaScript para entender o que estamos fazendo.
116125

1-js/04-object-basics/07-optional-chaining/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,4 @@ As we can see, all of them are straightforward and simple to use. The `?.` check
219219
220220
A chain of `?.` allows to safely access nested properties.
221221
222-
Still, we should apply `?.` carefully, only where it's acceptable that the left part doesn't to exist. So that it won't hide programming errors from us, if they occur.
222+
Still, we should apply `?.` carefully, only where it's acceptable that the left part doesn't exist. So that it won't hide programming errors from us, if they occur.

1-js/05-data-types/02-number/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ JavaScript has a built-in [Math](https://developer.mozilla.org/en/docs/Web/JavaS
383383
A few examples:
384384

385385
`Math.random()`
386-
: Returns a random number from 0 to 1 (not including 1)
386+
: Returns a random number from 0 to 1 (not including 1).
387387

388388
```js run
389389
alert( Math.random() ); // 0.1234567894322
@@ -400,7 +400,7 @@ A few examples:
400400
```
401401

402402
`Math.pow(n, power)`
403-
: Returns `n` raised the given power
403+
: Returns `n` raised to the given power.
404404

405405
```js run
406406
alert( Math.pow(2, 10) ); // 2 in power 10 = 1024

1-js/05-data-types/06-iterable/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ When we use JavaScript for practical tasks in a browser or any other environment
174174

175175
For instance, strings are both iterable (`for..of` works on them) and array-like (they have numeric indexes and `length`).
176176

177-
But an iterable may not be array-like. And vice versa an array-like may not be iterable.
177+
But an iterable may be not array-like. And vice versa an array-like may be not iterable.
178178

179179
For example, the `range` in the example above is iterable, but not array-like, because it does not have indexed properties and `length`.
180180

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,23 @@ alert(test); // true, the variable lives after if
4242
*/!*
4343
```
4444

45+
<<<<<<< HEAD
4546
If we used `let test` on the 2nd line, then it wouldn't be visible to `alert`. But `var` ignores code blocks, so we've got a global `test`.
47+
=======
48+
As `var` ignores code blocks, we've got a global variable `test`.
49+
50+
If we used `let test` instead of `var test`, then the variable would only be visible inside `if`:
51+
52+
```js run
53+
if (true) {
54+
let test = true; // use "let"
55+
}
56+
57+
*!*
58+
alert(test); // ReferenceError: test is not defined
59+
*/!*
60+
```
61+
>>>>>>> 039716de8a96f49b5fccd7aed5effff2e719dfe5
4662
4763
The same thing for loops: `var` cannot be block- or loop-local:
4864

@@ -70,7 +86,7 @@ function sayHi() {
7086
}
7187

7288
sayHi();
73-
alert(phrase); // Error: phrase is not defined
89+
alert(phrase); // ReferenceError: phrase is not defined
7490
```
7591

7692
As we can see, `var` pierces through `if`, `for` or other code blocks. That's because a long time ago in JavaScript, blocks had no Lexical Environments, and `var` is a remnant of that.
@@ -216,7 +232,7 @@ The Function Expression is wrapped with parenthesis `(function {...})`, because
216232

217233
```js run
218234
// Tries to declare and immediately call a function
219-
function() { // <-- Error: Function statements require a function name
235+
function() { // <-- SyntaxError: Function statements require a function name
220236

221237
var message = "Hello";
222238

1-js/11-async/07-microtask-queue/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Why did the `.then` trigger afterwards? What's going on?
2323

2424
# Microtasks
2525

26-
Asynchronous tasks need proper management. For that, the ECMA standard specifies an internal queue `PromiseJobs`, more often referred to as the "microtask queue" (ES8 term).
26+
Asynchronous tasks need proper management. For that, the ECMA standard specifies an internal queue `PromiseJobs`, more often referred to as the "microtask queue" (V8 term).
2727

2828
As stated in the [specification](https://tc39.github.io/ecma262/#sec-jobs-and-job-queues):
2929

@@ -179,7 +179,7 @@ In the example above, `.catch` added by `setTimeout` also triggers. But it does
179179

180180
- There's also a "macrotask queue" that keeps various events, network operation results, `setTimeout`-scheduled calls, and so on. These are also called "macrotasks" (v8 term).
181181

182-
Promise handling is always asynchronous, as all promise actions pass through the internal "promise jobs" queue, also called "microtask queue" (ES8 term).
182+
Promise handling is always asynchronous, as all promise actions pass through the internal "promise jobs" queue, also called "microtask queue" (V8 term).
183183

184184
So `.then/catch/finally` handlers are always called after the current code is finished.
185185

2-ui/1-document/04-searching-elements-dom/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ For instance:
142142

143143
*Ancestors* of an element are: parent, the parent of parent, its parent and so on. The ancestors together form the chain of parents from the element to the top.
144144

145-
The method `elem.closest(css)` looks the nearest ancestor that matches the CSS-selector. The `elem` itself is also included in the search.
145+
The method `elem.closest(css)` looks for the nearest ancestor that matches the CSS-selector. The `elem` itself is also included in the search.
146146

147147
In other words, the method `closest` goes up from the element and checks each of parents. If it matches the selector, then the search stops, and the ancestor is returned.
148148

2-ui/3-event-details/7-keyboard-events/article.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ In the past, there was a `keypress` event, and also `keyCode`, `charCode`, `whic
170170

171171
There were so many browser incompatibilities while working with them, that developers of the specification had no way, other than deprecating all of them and creating new, modern events (described above in this chapter). The old code still works, as browsers keep supporting them, but there's totally no need to use those any more.
172172

173+
## Mobile Keyboards
174+
175+
When using virtual/mobile keyboards, formally known as IME (Input-Method Editor), the W3C standard states that a KeyboardEvent's [`e.keyCode` should be `229`](https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode) and [`e.key` should be `"Unidentified"`](https://www.w3.org/TR/uievents-key/#key-attr-values).
176+
177+
While some of these keyboards might still use the right values for `e.key`, `e.code`, `e.keyCode`... when pressing certain keys such as arrows or backspace, there's no guarantee, so your keyboard logic might not always work on mobile devices.
178+
173179
## Summary
174180

175181
Pressing a key always generates a keyboard event, be it symbol keys or special keys like `key:Shift` or `key:Ctrl` and so on. The only exception is `key:Fn` key that sometimes presents on a laptop keyboard. There's no keyboard event for it, because it's often implemented on lower level than OS.

5-network/04-fetch-abort/article.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ When `abort()` is called:
2525
- `controller.signal.aborted` property becomes `true`.
2626

2727
Generally, we have two parties in the process:
28-
1. The one that performs an cancelable operation, it sets a listener on `controller.signal`.
28+
1. The one that performs a cancelable operation, it sets a listener on `controller.signal`.
2929
2. The one that cancels: it calls `controller.abort()` when needed.
3030

3131
Here's the full example (without `fetch` yet):
@@ -35,7 +35,7 @@ let controller = new AbortController();
3535
let signal = controller.signal;
3636

3737
// The party that performs a cancelable operation
38-
// gets "signal" object
38+
// gets the "signal" object
3939
// and sets the listener to trigger when controller.abort() is called
4040
signal.addEventListener('abort', () => alert("abort!"));
4141

@@ -46,15 +46,15 @@ controller.abort(); // abort!
4646
alert(signal.aborted); // true
4747
```
4848

49-
As we can see, `AbortController` is just a means to pass `abort` events when `abort()` is called on it.
49+
As we can see, `AbortController` is just a mean to pass `abort` events when `abort()` is called on it.
5050

51-
We could implement same kind of event listening in our code on our own, without `AbortController` object at all.
51+
We could implement the same kind of event listening in our code on our own, without the `AbortController` object.
5252

53-
But what's valuable is that `fetch` knows how to work with `AbortController` object, it's integrated with it.
53+
But what's valuable is that `fetch` knows how to work with the `AbortController` object. It's integrated in it.
5454

5555
## Using with fetch
5656

57-
To become able to cancel `fetch`, pass the `signal` property of an `AbortController` as a `fetch` option:
57+
To be able to cancel `fetch`, pass the `signal` property of an `AbortController` as a `fetch` option:
5858

5959
```js
6060
let controller = new AbortController();
@@ -97,7 +97,7 @@ try {
9797

9898
## AbortController is scalable
9999

100-
`AbortController` is scalable, it allows to cancel multiple fetches at once.
100+
`AbortController` is scalable. It allows to cancel multiple fetches at once.
101101

102102
Here's a sketch of code that fetches many `urls` in parallel, and uses a single controller to abort them all:
103103

@@ -113,7 +113,7 @@ let fetchJobs = urls.map(url => fetch(url, {
113113

114114
let results = await Promise.all(fetchJobs);
115115

116-
// if controller.abort() is called from elsewhere,
116+
// if controller.abort() is called from anywhere,
117117
// it aborts all fetches
118118
```
119119

@@ -137,12 +137,12 @@ let fetchJobs = urls.map(url => fetch(url, { // fetches
137137
// Wait for fetches and our task in parallel
138138
let results = await Promise.all([...fetchJobs, ourJob]);
139139

140-
// if controller.abort() is called from elsewhere,
140+
// if controller.abort() is called from anywhere,
141141
// it aborts all fetches and ourJob
142142
```
143143

144144
## Summary
145145

146-
- `AbortController` is a simple object that generates `abort` event on it's `signal` property when `abort()` method is called (and also sets `signal.aborted` to `true`).
147-
- `fetch` integrates with it: we pass `signal` property as the option, and then `fetch` listens to it, so it becomes possible to abort the `fetch`.
146+
- `AbortController` is a simple object that generates an `abort` event on it's `signal` property when the `abort()` method is called (and also sets `signal.aborted` to `true`).
147+
- `fetch` integrates with it: we pass the `signal` property as the option, and then `fetch` listens to it, so it's possible to abort the `fetch`.
148148
- We can use `AbortController` in our code. The "call `abort()`" -> "listen to `abort` event" interaction is simple and universal. We can use it even without `fetch`.

5-network/07-url/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Here's the cheatsheet for URL components:
6565
```smart header="We can pass `URL` objects to networking (and most other) methods instead of a string"
6666
We can use a `URL` object in `fetch` or `XMLHttpRequest`, almost everywhere where a URL-string is expected.
6767

68-
Generally, `URL` object can be passed to any method instead of a string, as most method will perform the string conversion, that turns a `URL` object into a string with full URL.
68+
Generally, the `URL` object can be passed to any method instead of a string, as most methods will perform the string conversion, that turns a `URL` object into a string with full URL.
6969
```
7070
7171
## SearchParams "?..."
@@ -80,7 +80,7 @@ new URL('https://google.com/search?query=JavaScript')
8080

8181
...But parameters need to be encoded if they contain spaces, non-latin letters, etc (more about that below).
8282

83-
So there's URL property for that: `url.searchParams`, an object of type [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams).
83+
So there's a URL property for that: `url.searchParams`, an object of type [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams).
8484

8585
It provides convenient methods for search parameters:
8686

@@ -201,7 +201,7 @@ So we should use only `encodeURIComponent` for each search parameter, to correct
201201
````smart header="Encoding difference compared to `URL`"
202202
Classes [URL](https://url.spec.whatwg.org/#url-class) and [URLSearchParams](https://url.spec.whatwg.org/#interface-urlsearchparams) are based on the latest URI specification: [RFC3986](https://tools.ietf.org/html/rfc3986), while `encode*` functions are based on the obsolete version [RFC2396](https://www.ietf.org/rfc/rfc2396.txt).
203203

204-
There are few differences, e.g. IPv6 addresses are encoded differently:
204+
There are a few differences, e.g. IPv6 addresses are encoded differently:
205205

206206
```js run
207207
// valid url with IPv6 address

0 commit comments

Comments
 (0)