diff options
| author | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:45:38 +0100 |
|---|---|---|
| committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:45:38 +0100 |
| commit | 4ab365b110f2f1f2b736326b7059244a32115089 (patch) | |
| tree | c3c7c0219f728ade49a78c238c51cc0c8d06ebd6 /files/de/web/javascript/reference/errors/cant_access_property | |
| parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
| download | translated-content-4ab365b110f2f1f2b736326b7059244a32115089.tar.gz translated-content-4ab365b110f2f1f2b736326b7059244a32115089.tar.bz2 translated-content-4ab365b110f2f1f2b736326b7059244a32115089.zip | |
unslug de: move
Diffstat (limited to 'files/de/web/javascript/reference/errors/cant_access_property')
| -rw-r--r-- | files/de/web/javascript/reference/errors/cant_access_property/index.html | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/errors/cant_access_property/index.html b/files/de/web/javascript/reference/errors/cant_access_property/index.html new file mode 100644 index 0000000000..98471eb28e --- /dev/null +++ b/files/de/web/javascript/reference/errors/cant_access_property/index.html @@ -0,0 +1,59 @@ +--- +title: 'TypeError: can''t access property "x" of "y"' +slug: Web/JavaScript/Reference/Fehler/Cant_access_property +tags: + - Fehler + - JavaScript + - TypeError +translation_of: Web/JavaScript/Reference/Errors/Cant_access_property +--- +<div>{{jsSidebar("Errors")}}</div> + +<h2 id="Fehlermeldung">Fehlermeldung</h2> + +<pre class="syntaxbox">TypeError: Unable to get property {x} of undefined or null reference (Edge) +TypeError: can't access property {x} of {y} (Firefox) +TypeError: {y} is undefined, can't access property {x} of it (Firefox) +TypeError: {y} is null, can't access property {x} of it (Firefox) + +Beispiele: +TypeError: x is undefined, can't access property "prop" of it +TypeError: x is null, can't access property "prop" of it +TypeError: can't access property "prop" of undefined +TypeError: can't access property "prop" of null +</pre> + +<h2 id="Fehlertyp">Fehlertyp</h2> + +<p>{{jsxref("TypeError")}}.</p> + +<h2 id="Was_ist_falsch_gelaufen">Was ist falsch gelaufen?</h2> + +<p>The Attributzugriff erfolgte über einen {{jsxref("undefined")}} oder {{jsxref("null")}} Wert</p> + +<h2 id="Beispiele">Beispiele</h2> + +<h3 id="Invalide_Fälle">Invalide Fälle</h3> + +<pre class="brush: js example-bad">// undefined und null sind Fälle auf denen die Methode substring nicht aufgerufen werden kann +var foo = undefined; +foo.substring(1); // TypeError: x is undefined, can't access property "substring" of it + +var foo = null; +foo.substring(1); // TypeError: x is null, can't access property "substring" of it +</pre> + +<h3 id="Fehlerbehebung">Fehlerbehebung</h3> + +<p>Um den null pointer auf <code>undefined</code> oder <code>null</code> Werte zu beheben, kann beispielsweise der <a href="/en-US/docs/Web/JavaScript/Reference/Operators/typeof">typeof</a> Operator verwendet werden.</p> + +<pre class="brush: js">if (typeof foo !== 'undefined') { + // Hier wissen wir, dass foo definiert ist +}</pre> + +<h2 id="Siehe_auch">Siehe auch</h2> + +<ul> + <li>{{jsxref("undefined")}}</li> + <li>{{jsxref("null")}}</li> +</ul> |
