Optional chaining '?.'#90
Open
johannesdominik wants to merge 2 commits intojavascript-tutorial:masterfrom
untypedjay:master
Open
Optional chaining '?.'#90johannesdominik wants to merge 2 commits intojavascript-tutorial:masterfrom untypedjay:master
johannesdominik wants to merge 2 commits intojavascript-tutorial:masterfrom
untypedjay:master
Conversation
Falke-Design
left a comment
There was a problem hiding this comment.
Ich weiß nicht ob es gewollt ist, dass manche Ein-Zeiler, zwei Zeilen haben.
Comment on lines
+6
to
+7
| Der Optionale-Verkettungs-Operator `?.` ermöglicht es, auf einen Wert einer verschachtelten | ||
| Objekteigenschaft zuzugreifen, ohne dass jede Eigenschaft existieren muss. |
Comment on lines
+11
to
+12
| Personen, die erst gerade dabei sind, JavaScript zu lernen, kamen wahrscheinlich mit diesem | ||
| Problem noch nicht in Berührung, allerdings tritt dieses sehr häufig in der Praxis auf. |
Comment on lines
+14
to
+15
| Beispielsweise haben einige unserer Benutzer eine Adresse, allerdings fehlt diese bei manchen. | ||
| Dadurch ist die Verwendung von `user.address.street` nicht sicher: |
Comment on lines
+23
to
+24
| Oder man möchte in der Webentwicklung auf ein bestimmtes Element auf der Webseite zugreifen, | ||
| das aber möglicherweise gar nicht existiert: |
Comment on lines
+31
to
+32
| Vor der Einführung von `?.` in die Sprache wurde oft der `&&` Operator verwendet, um das | ||
| Problem zu umgehen. |
Comment on lines
+42
to
+43
| Den gesamten Pfad und die Eigenschaft mit UND zu verknüpfen stellt sicher, dass alle Komponenten | ||
| existieren. Allerdings ist dies sehr umständlich. |
Comment on lines
+47
to
+48
| Der Optionale-Verkettungs-Operator (Optional Chaining) `?.` stoppt die Auswertung und gibt | ||
| `undefined` zurück, sobald der Teil vor `?.` zu `undefined` oder `null` evaluiert. |
Comment on lines
+50
to
+51
| **Aus Platzgründen verwenden wir im weiteren Verlauf dieses Artikels den Begriff | ||
| "etwas existiert", wenn etwas nicht `null` oder `undefined` ist.** |
Comment on lines
+61
to
+62
| Es ist sogar möglich, die Adresse von `user?.address` zu lesen, obwohl das Objekt `user` | ||
| gar nicht existiert: |
Comment on lines
+75
to
+76
| Wenn `user` allerdings existiert, so muss das Objekt die Eigenschaft `user.address` besitzen, | ||
| sonst liefert `user?.address.street` beim zweiten Punkt einen Fehler. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.