Skip to content

Commit 8073fc7

Browse files
committed
merging all conflicts
2 parents 75b3067 + 23da191 commit 8073fc7

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

1-js/02-first-steps/01-hello-world/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ Então, primeiro, vamos ver como anexar um script a uma página. Para ambientes
99

1010
## A tag "script"
1111

12+
<<<<<<< HEAD
1213
Os programas JavaScript podem ser inseridos em qualquer parte de um documento HTML com a ajuda da tag `<script>`.
14+
=======
15+
JavaScript programs can be inserted almost anywhere into an HTML document using the `<script>` tag.
16+
>>>>>>> 23da191b58643387783f38e999f5b05be87d3d93
1317
1418
Por exemplo:
1519

1-js/04-object-basics/01-object/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ let user = {
9292
```
9393
Esta é chamada de vírgula à direita (*trailing comma*) ou "vírgula pendurada" (*hanging comma*). Ela facilita o adicionar/remover/mover propriedades, porque todas as linhas se tornam semelhantes.
9494

95+
<<<<<<< HEAD
9596
````smart header="Objeto com const pode ser alterado"
9697
Por favor, note: um objeto declarado como `const` *pode* ser modificado.
9798
@@ -117,6 +118,9 @@ Há outra forma para tornar constantes as propriedades de um objeto, que iremos
117118
````
118119

119120
## Parênteses retos
121+
=======
122+
## Square brackets
123+
>>>>>>> 23da191b58643387783f38e999f5b05be87d3d93
120124
121125
Para propriedades com múltiplas palavras, o acesso por ponto não funciona:
122126

1-js/04-object-basics/02-object-copy/article.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ admin.name = 'Pete'; // changed by the "admin" reference
7373
alert(*!*user.name*/!*); // 'Pete', changes are seen from the "user" reference
7474
```
7575
76-
7776
It's just as if we had a cabinet with two keys and used one of them (`admin`) to get into it. Then, if we later use another key (`user`) we can see changes.
7877
7978
## Comparison by reference
@@ -230,6 +229,30 @@ To fix that, we should use the cloning loop that examines each value of `user[ke
230229
231230
We can use recursion to implement it. Or, not to reinvent the wheel, take an existing implementation, for instance [_.cloneDeep(obj)](https://lodash.com/docs#cloneDeep) from the JavaScript library [lodash](https://lodash.com).
232231
232+
```smart header="Const objects can be modified"
233+
An important "side effect" of storing objects as references is that an object declared as `const` *can* be modified.
234+
235+
For instance:
236+
237+
```js run
238+
const user = {
239+
name: "John"
240+
};
241+
242+
*!*
243+
user.name = "Pete"; // (*)
244+
*/!*
245+
246+
alert(user.name); // Pete
247+
```
248+
249+
It might seem that the line `(*)` would cause an error, but no. The value of `user` is constant, it must always reference the same object. But properties of that object are free to change.
250+
251+
In other words, the `const user` gives an error only if we try to set `user=...` as a whole, and that's all.
252+
253+
That said, if we really need to make constant object properties, it's also possible, but using totally different methods, we'll mention that in the chapter <info:property-descriptors>.
254+
```
255+
233256
## Summary
234257
235258
Objects are assigned and copied by reference. In other words, a variable stores not the "object value", but a "reference" (address in memory) for the value. So copying such a variable or passing it as a function argument copies that reference, not the object.

2-ui/4-forms-controls/3-events-change-input/article.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,23 @@ For instance, the code below prevents all such events and shows what we are tryi
6262
</script>
6363
```
6464

65+
<<<<<<< HEAD
6566
Technically, we can copy/paste everything. For instance, we can copy a file in the OS file manager, and paste it.
6667

6768
There's a list of methods [in the specification](https://www.w3.org/TR/clipboard-apis/#dfn-datatransfer) to work with different data types, read/write to the clipboard.
6869

6970
But please note that clipboard is a "global" OS-level thing. Most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety. Also it is forbidden to create "custom" clipboard events in all browsers except Firefox.
71+
=======
72+
Please note, that it's possible to copy/paste not just text, but everything. For instance, we can copy a file in the OS file manager, and paste it.
73+
74+
That's because `clipboardData` implements `DataTransfer` interface, commonly used for drag'n'drop and copy/pasting. It's bit beyound our scope now, but you can find its methods [in the specification](https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface).
75+
76+
```warn header="ClipboardAPI: user safety restrictions"
77+
The clipboard is a "global" OS-level thing. So most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety, e.g. in `onclick` event handlers.
78+
79+
Also it's forbidden to generate "custom" clipboard events with `dispatchEvent` in all browsers except Firefox.
80+
```
81+
>>>>>>> 23da191b58643387783f38e999f5b05be87d3d93
7082
7183
## Summary
7284

0 commit comments

Comments
 (0)