Skip to content

Commit 123fe3f

Browse files
authored
Merge branch 'master' into master
2 parents d451795 + 28ddd6c commit 123fe3f

File tree

5 files changed

+116
-31
lines changed

5 files changed

+116
-31
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ Men, du behøver et miljø til at afvikle dine scripts og siden denne bog er en
66

77
Først, lad os se, hvordan du kobler et script til en webside. For server-side miljøer som Node.js, kan du afvikle scripts med kommandoen`"node my.js"`.
88

9-
109
## "script" tagget
11-
1210
JavaScript programmer kan blive sat ind i alle dele af et HTML-dokument ved hjælp af et `<script>` tag.
1311

1412
For eksempel:

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,6 @@ let user = {
9292
```
9393
That is called a "trailing" or "hanging" comma. Makes it easier to add/remove/move around properties, because all lines become alike.
9494

95-
````smart header="Object with const can be changed"
96-
Please note: an object declared as `const` *can* be modified.
97-
98-
For instance:
99-
100-
```js run
101-
const user = {
102-
name: "John"
103-
};
104-
105-
*!*
106-
user.name = "Pete"; // (*)
107-
*/!*
108-
109-
alert(user.name); // Pete
110-
```
111-
112-
It might seem that the line `(*)` would cause an error, but no. The `const` fixes the value of `user`, but not its contents.
113-
114-
The `const` would give an error only if we try to set `user=...` as a whole.
115-
116-
There's another way to make constant object properties, we'll cover it later in the chapter <info:property-descriptors>.
117-
````
118-
11995
## Square brackets
12096

12197
For multiword properties, the dot access doesn't work:

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ For instance, the code below prevents all such events and shows what we are tryi
7676

7777
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.
7878

79-
There's a list of methods [in the specification](https://www.w3.org/TR/clipboard-apis/#dfn-datatransfer) that can work with different data types including files, read/write to the clipboard.
79+
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).
8080

81-
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, e.g. in `onclick` event handlers.
81+
```warn header="ClipboardAPI: user safety restrictions"
82+
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.
8283
8384
Also it's forbidden to generate "custom" clipboard events with `dispatchEvent` in all browsers except Firefox.
85+
```
8486

8587
## Summary
8688

README.md

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@
33
This repository hosts the translation of <https://javascript.info> in Danish.
44

55

6+
**That's how you can contribute:**
7+
8+
- See the [Danish Translate Progress](https://github.com/javascript-tutorial/da.javascript.info/issues/1) issue.
9+
- Choose an unchecked article you'd like to translate.
10+
- Add a comment with the article title to the issue, e.g. `An Introduction to JavaScript`.
11+
- Our bot will mark it in the issue, for everyone to know that you're translating it.
12+
- Your comment should contain only the title.
13+
- Fork the repository, translate and send a PR when done.
14+
- PR title should match article title, the bot will write it's number into the issue.
15+
16+
Please kindly allow maintainers to review and merge or request changes in your translation.
17+
18+
If maintainers do not respond, or if you'd like to become a maintainer, write us at the [main repo](https://github.com/javascript-tutorial/en.javascript.info/issues/new).
19+
20+
**Let others know what you're translating, in message boards or chats in your language. Invite them to join!**
21+
22+
🎉 Thank you!
23+
24+
Your name and the contribution size will appear in the "About project" page when the translation gets published.
25+
26+
P.S. The full list of languages can be found at <https://javascript.info/translate>.
27+
28+
This repository hosts the translation of <https://javascript.info> in Danish.
29+
630
**That's how you can contribute:**
731

832
- See the [Danish Translate Progress](https://github.com/javascript-tutorial/da.javascript.info/issues/1) issue.
@@ -53,6 +77,69 @@ If you see that the English version can be improved – great, please send a PR
5377
- For other terms like `resolved promise`, `slash`, `regexp`, and so on - look for a glossary, hopefully there's one for your language already. If not, look for translations in manuals, such as [MDN](https://developer.mozilla.org/en-US/).
5478

5579

80+
### Terms with meaning
81+
82+
In English many terms have an obvious meaning. For a person who doesn't understand English, there's no such meaning.
83+
84+
Please keep that in mind, sometimes explanations or additional translations are needed, e.g.
85+
86+
```md
87+
`ReadableStream` objects allows to read data chunk-by-chunk.
88+
```
89+
90+
```md
91+
`ReadableStream` ("flujo legible") objeto ...
92+
```
93+
94+
### Text in Code Blocks
95+
96+
- Translate comments.
97+
- Translate user-messages and example strings.
98+
- Don't translate variables, classes, identifiers.
99+
- Ensure that the code works after the translation :)
100+
101+
Example:
102+
103+
```js
104+
// Example
105+
const text = "Hello, world";
106+
document.querySelector('.hello').innerHTML = text;
107+
```
108+
109+
✅ DO (translate comment):
110+
111+
```js
112+
// Ejemplo
113+
const text = 'Hola mundo';
114+
document.querySelector('.hello').innerHTML = text;
115+
```
116+
117+
Every chapter, an article or a task resides in its own folder.
118+
119+
The folder is named `N-url`, where `N` – is the number for sorting (articles are ordered), and `url` is the URL-slug on the site.
120+
121+
The folder has one of files:
122+
123+
- `index.md` for a section,
124+
- `article.md` for an article,
125+
- `task.md` for a task formulation (+`solution.md` with the solution text if any).
126+
127+
A file starts with the `# Title Header`, and then the text in Markdown-like format, editable in a simple text editor.
128+
129+
Additional resources and examples for the article or the task, are also in the same folder.
130+
131+
## Translation Tips
132+
133+
Please keep line breaks and paragraphs "as is": don't add newlines and don't remove existing ones. Makes it easy to merge future changes from the English version into the translation.
134+
135+
If you see that the English version can be improved – great, please send a PR to it.
136+
137+
### Terms
138+
139+
- Some specification terms are not to be translated, e.g. "Function Declaration" can be left "as is".
140+
- For other terms like `resolved promise`, `slash`, `regexp`, and so on - look for a glossary, hopefully there's one for your language already. If not, look for translations in manuals, such as [MDN](https://developer.mozilla.org/en-US/).
141+
142+
56143
### Terms with meaning
57144

58145
In English many terms have an obvious meaning. For a person who doesn't understand English, there's no such meaning.
@@ -103,12 +190,11 @@ document.querySelector('.hola').innerHTML = text;
103190
Please note, that sometimes code is followed by pictures, and if you translate text `Hello` -> `Hola` in the code, you need to translate text in picturess as well.
104191

105192
In that case it's probably easier not to translate such text. See more about translating images later.
106-
=======
193+
107194
- `index.md` stands for a chapter
108195
- `article.md` stands for an article
109196
- `task.md` stands for a task (solution must be provided in `solution.md` file as well)
110197

111-
112198
### External Links
113199

114200
If an external link is to Wikipedia, e.g. `https://en.wikipedia.org/wiki/JavaScript`, and a version of that article exists in your language that is of decent quality, link to that version instead.

0 commit comments

Comments
 (0)