You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/04-variables/article.md
+47Lines changed: 47 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -103,16 +103,26 @@ In older scripts, you may also find another keyword: `var` instead of `let`:
103
103
*!*var*/!* message ='Hello';
104
104
```
105
105
106
+
<<<<<<< HEAD
106
107
Das `var` Schlüsselwort ist *fast* dasselbe wie `let`. Es deklariert auch eine Variable, aber auf eine etwas andere, "altbackene" Weise.
107
108
108
109
Es gibt subtile Unterschiede zwischen `let` und `var`, aber sie sind für uns noch nicht wichtig. Wir werden sie im Kapitel <info:var> ausführlich behandeln.
110
+
=======
111
+
The `var` keyword is *almost* the same as `let`. It also declares a variable but in a slightly different, "old-school" way.
112
+
113
+
There are subtle differences between `let` and `var`, but they do not matter to us yet. We'll cover them in detail in the chapter <info:var>.
114
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
109
115
````
110
116
111
117
## Eine Analogie aus dem wirklichen Leben
112
118
113
119
Wir können das Konzept einer "Variablen" leicht verstehen, wenn wir sie uns als eine "Kiste" für Daten vorstellen, mit einem eindeutig benannten Aufkleber darauf.
114
120
121
+
<<<<<<< HEAD
115
122
Zum Beispiel kann man sich die Variable `message` als eine Kiste vorstellen mit der Bezeichnung `"message"` und dem Wert `"Hello!"` darin:
123
+
=======
124
+
For instance, the variable `message` can be imagined as a box labelled `"message"` with the value `"Hello!"` in it:
125
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
116
126
117
127

118
128
@@ -238,19 +248,27 @@ Variables named `apple` and `APPLE` are two different variables.
238
248
```
239
249
240
250
````smart header="Non-Latin letters are allowed, but not recommended"
251
+
<<<<<<< HEAD
241
252
It is possible to use any language, including cyrillic letters, Chinese logograms and so on, like this:
242
253
>>>>>>> d694e895efe89922a109702085b6ca1efeffea10
254
+
=======
255
+
It is possible to use any language, including Cyrillic letters, Chinese logograms and so on, like this:
256
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
243
257
244
258
```js
245
259
let имя = '...';
246
260
let 我 = '...';
247
261
```
248
262
263
+
<<<<<<< HEAD
249
264
<<<<<<< HEAD
250
265
Technisch gesehen gibt es hier keinen Fehler, solche Namen sind erlaubt, aber es gibt eine internationale Tradition, Englisch in Variablennamen zu verwenden. Selbst wenn wir ein kleines Script schreiben, kann es ein langes Leben vor sich haben. Menschen aus anderen Ländern müssen es vielleicht irgendwann einmal lesen.
251
266
=======
252
267
Technically, there is no error here. Such names are allowed, but there is an international convention to use English in variable names. Even if we're writing a small script, it may have a long life ahead. People from other countries may need to read it some time.
253
268
>>>>>>> d35baee32dcce127a69325c274799bb81db1afd8
269
+
=======
270
+
Technically, there is no error here. Such names are allowed, but there is an international convention to use English in variable names. Even if we're writing a small script, it may have a long life ahead. People from other countries may need to read it sometime.
myBirthday = '01.01.2001'; // Fehler, Konstante kann nicht neu zugewiesen werden!
306
324
```
307
325
326
+
<<<<<<< HEAD
308
327
Wenn ein Programmierer sicher ist, dass eine Variable sich nie ändern wird, kann er sie mit `const` deklarieren, um diese Tatsache zu garantieren und jedem klar zu kommunizieren.
309
328
310
329
<<<<<<< HEAD
330
+
=======
331
+
When a programmer is sure that a variable will never change, they can declare it with `const` to guarantee and communicate that fact to everyone.
332
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
311
333
312
334
### Konstanten in Großbuchstaben
313
335
=======
314
336
### Uppercase constants
315
337
>>>>>>> d694e895efe89922a109702085b6ca1efeffea10
316
338
339
+
<<<<<<< HEAD
317
340
Es ist eine weit verbreitete Vorgehensweise, Konstanten als Alias für schwer zu merkende Werte zu verwenden, die bereits vor der Ausführung bekannt sind.
341
+
=======
342
+
There is a widespread practice to use constants as aliases for difficult-to-remember values that are known before execution.
343
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
318
344
319
345
Solche Konstanten werden mit Großbuchstaben und Unterstrichen benannt.
320
346
@@ -339,7 +365,11 @@ Vorteile:
339
365
340
366
Wann sollten wir Großbuchstaben für eine Konstante verwenden und wann sollten wir sie normal benennen? Lass uns das klarstellen.
341
367
368
+
<<<<<<< HEAD
342
369
Eine "Konstante" zu sein bedeutet nur, dass sich der Wert einer Variablen nie ändert. Aber es gibt Konstanten, die vor der Ausführung bekannt sind (wie ein hexadezimaler Wert für die Farbe rot) und es gibt Konstanten, die zur Laufzeit, also während der Ausführung, *berechnet* werden, sich aber nach ihrer anfänglichen Zuweisung nicht mehr ändern.
370
+
=======
371
+
Being a "constant" just means that a variable's value never changes. But some constants are known before execution (like a hexadecimal value for red) and some constants are *calculated* in run-time, during the execution, but do not change after their initial assignment.
372
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
343
373
344
374
<<<<<<< HEAD
345
375
Zum Beispiel:
@@ -351,7 +381,11 @@ For instance:
351
381
const pageLoadTime = /* Zeit, die eine Website braucht, um geladen zu werden */;
352
382
```
353
383
384
+
<<<<<<< HEAD
354
385
Der Wert von `pageLoadTime` ist vor dem Laden der Seite nicht bekannt, daher wird er normal benannt. Aber es ist immer noch eine Konstante, weil er sich nach der Zuweisung nicht mehr ändert.
386
+
=======
387
+
The value of `pageLoadTime` is not known before the page load, so it's named normally. But it's still a constant because it doesn't change after the assignment.
388
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
355
389
356
390
<<<<<<< HEAD
357
391
Mit anderen Worten, großgeschriebene Konstanten werden nur als Aliase für "hart kodierte" Werte verwendet.
@@ -365,18 +399,31 @@ Apropos Variablen, es gibt noch eine extrem wichtige Sache.
365
399
366
400
Ein Variablenname sollte eine saubere, offensichtliche Bedeutung haben, die die Daten beschreibt, die er speichert.
367
401
402
+
<<<<<<< HEAD
368
403
Die Benennung von Variablen ist eine der wichtigsten und komplexesten Fähigkeiten in der Programmierung. Ein schneller Blick auf Variablennamen kann zeigen, welcher Code von einem Anfänger im Gegensatz zu einem erfahrenen Entwickler geschrieben wurde.
369
404
370
405
In einem echten Projekt wird die meiste Zeit damit verbracht, eine bestehende Codebasis zu modifizieren und zu erweitern, anstatt etwas völlig Neues zu schreiben. Wenn wir zu irgendeinem Code zurückkehren, nachdem wir eine Weile etwas anderes gemacht haben, ist es viel einfacher Informationen zu finden, die gut beschriftet sind. Oder, mit anderen Worten, wenn die Variablen gute Namen haben.
406
+
=======
407
+
Variable naming is one of the most important and complex skills in programming. A glance at variable names can reveal which code was written by a beginner versus an experienced developer.
408
+
409
+
In a real project, most of the time is spent modifying and extending an existing code base rather than writing something completely separate from scratch. When we return to some code after doing something else for a while, it's much easier to find information that is well-labelled. Or, in other words, when the variables have good names.
410
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
371
411
372
412
Bitte denk über den richtigen Namen für eine Variable nach, bevor du sie deklarierst. Das wird sich ordentlich auszahlen.
373
413
374
414
Einige Regeln, die gut zu befolgen sind:
375
415
416
+
<<<<<<< HEAD
376
417
- Verwende menschenlesbare Namen, wie `userName` oder `shoppingCart`.
377
418
- Halte dich fern von Abkürzungen oder Kürzel wie `a`, `b`, `c`, es sei denn, du weißt wirklich, was du tust.
378
419
- Mach Namen maximal beschreibend und prägnant. Beispiele für schlechte Namen sind `data` und `value`. Solche Namen sagen nichts aus. Es ist nur in Ordnung, sie zu benutzen, wenn der Kontext des Codes es außergewöhnlich offensichtlich macht, auf welche Daten oder Werte die Variable verweist.
379
420
- Mach dir mit dir selbst und deinem Team Bedingungen aus. Wenn ein Website Besucher "user" genannt wird, dann sollten verwandte Variablen `currentUser` oder `newUser` heißen, anstatt `currentVisitor` oder `newManInTown`.
421
+
=======
422
+
- Use human-readable names like `userName` or `shoppingCart`.
423
+
- Stay away from abbreviations or short names like `a`, `b`, and `c`, unless you know what you're doing.
424
+
- Make names maximally descriptive and concise. Examples of bad names are `data` and `value`. Such names say nothing. It's only okay to use them if the context of the code makes it exceptionally obvious which data or value the variable is referencing.
425
+
- Agree on terms within your team and in your mind. If a site visitor is called a "user" then we should name related variables `currentUser` or `newUser` instead of `currentVisitor` or `newManInTown`.
426
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
380
427
381
428
Klingt einfach? Ist es auch, aber die Erstellung von beschreibenden und prägnanten Variablennamen ist es in der Praxis nicht. Nur zu.
Da `BigInt`-Zahlen selten benötigt werden, behandeln wir sie hier nicht, sondern widmen ihnen ein eigenes Kapitel <info:bigint>. Lies es, wenn du so große Zahlen brauchst.
116
116
117
+
<<<<<<< HEAD
117
118
<<<<<<< HEAD
118
119
```smart header="Compatability issues"
119
120
Im Moment wird `BigInt` in Firefox/Chrome/Edge unterstützt, aber nicht in Safari/IE.
@@ -126,6 +127,8 @@ Right now, `BigInt` is supported in Firefox/Chrome/Edge/Safari, but not in IE.
126
127
127
128
You can check [*MDN* BigInt compatibility table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility) to know which versions of a browser are supported.
128
129
130
+
=======
131
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
129
132
## String
130
133
131
134
Ein String in JavaScript muss in Anführungszeichen gesetzt werden.
Copy file name to clipboardExpand all lines: 1-js/03-code-quality/06-polyfills/article.md
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,11 @@ Es ist also durchaus üblich, dass eine Engine nur einen Teil des Standards impl
15
15
So it's quite common for an engine to implement only part of the standard.
16
16
>>>>>>> d694e895efe89922a109702085b6ca1efeffea10
17
17
18
+
<<<<<<< HEAD
18
19
Eine gute Seite, um den aktuellen Stand der Unterstützung für Sprachfunktionen zu sehen, ist <https://kangax.github.io/compat-table/es6/> (es ist groß, wir haben noch viel zu lernen).
20
+
=======
21
+
A good page to see the current state of support for language features is <https://compat-table.github.io/compat-table/es6/> (it's big, we have a lot to study yet).
22
+
>>>>>>> b258d7d5b635c88228f7556e14fbe5e5ca7f736d
19
23
20
24
As programmers, we'd like to use most recent features. The more good stuff - the better!
21
25
@@ -129,7 +133,6 @@ JavaScript is a highly dynamic language. Scripts may add/modify any function, ev
129
133
130
134
Two interesting polyfill libraries are:
131
135
- [core js](https://github.com/zloirock/core-js) that supports a lot, allows to include only needed features.
132
-
- [polyfill.io](https://polyfill.io/) service that provides a script with polyfills, depending on the features and user's browser.
133
136
134
137
135
138
## Summary
@@ -141,7 +144,7 @@ Just don't forget to use a transpiler (if using modern syntax or operators) and
141
144
For example, later when you're familiar with JavaScript, you can setup a code build system based on [webpack](https://webpack.js.org/) with the [babel-loader](https://github.com/babel/babel-loader) plugin.
142
145
143
146
Good resources that show the current state of support for various features:
144
-
- <https://kangax.github.io/compat-table/es6/> - for pure JavaScript.
147
+
- <https://compat-table.github.io/compat-table/es6/> - for pure JavaScript.
145
148
- <https://caniuse.com/> - for browser-related functions.
146
149
147
150
P.S. Google Chrome is usually the most up-to-date with language features, try it if a tutorial demo fails. Most tutorial demos work with any modern browser though.
0 commit comments