diff options
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/null')
-rw-r--r-- | files/de/web/javascript/reference/global_objects/null/index.html | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/null/index.html b/files/de/web/javascript/reference/global_objects/null/index.html new file mode 100644 index 0000000000..323579ee42 --- /dev/null +++ b/files/de/web/javascript/reference/global_objects/null/index.html @@ -0,0 +1,93 @@ +--- +title: 'null' +slug: Web/JavaScript/Reference/Global_Objects/null +tags: + - JavaScript + - Literal + - Primitive +translation_of: Web/JavaScript/Reference/Global_Objects/null +--- +<div>{{jsSidebar("Objects")}}</div> + +<p>Der Wert <code>null</code> repräsentiert das absichtliche Fehlen eines Wertes. Es ist einer der {{Glossary("Primitive", "Primitiven Werte")}} in Javascript.</p> + +<div>{{EmbedInteractiveExample("pages/js/globalprops-null.html")}}</div> + + + +<h2 id="Syntax" name="Syntax">Syntax</h2> + +<pre class="syntaxbox"><code>null </code></pre> + +<h2 id="Description" name="Description">Beschreibung</h2> + +<p>Der Wert <code>null</code> wird als Literal geschrieben: <code>null</code>. Der Wert <code>null</code> ist ein Literal (keine Eigenschaft des <em>globalen Objektes</em> wie<em> </em>{{jsxref("Global_Objects/undefined", "undefined")}}). <span id="result_box" lang="de"><span>Stattdessen drückt null einen Mangel an Identifikation aus und zeigt an, dass eine Variable auf kein Objekt zeigt</span></span>. In APIs wird <code>null</code> oftmals an Stellen verwendet, an denen ein Objekt optional genutzt werden kann.</p> + +<pre class="brush: js">// foo existiert nicht. Es wurde nicht definiert und nirgendwo initialisiert: +foo; +"ReferenceError: foo is not defined" + +// foo existiert nun, aber die Variable hat keinen Typ oder Wert: +var foo = null; +foo; +"null" +</pre> + +<h3 id="Unterschied_zwischen_null_und_undefined">Unterschied zwischen <code>null</code> und <code>undefined</code></h3> + +<p>Wenn auf null geprüft wird, sollte nicht der Gleichheitsvergleich ({{jsxref("Operators/Comparison_Operators", "==", "#Equality")}}) mit dem Identitätsvergleich ({{jsxref("Operators/Comparison_Operators", "===", "#Identity")}}) verwechselt werden, weil bei der Prüfung auf Gleichheit eine <span class="dpf_sent" id="dpfsent_3">implizite </span>Typumwandlung vorgenommen wird.</p> + +<pre class="brush: js">typeof null // "object" (not "null" for legacy reasons) +typeof undefined // "undefined" +null === undefined // false +null == undefined // true +null === null // true +null == null // true +!null // true +isNaN(1 + null) // false +isNaN(1 + undefined) // true</pre> + +<h2 id="Spezifikationen">Spezifikationen</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Spezifikation</th> + <th scope="col">Status</th> + <th scope="col">Kommentar</th> + </tr> + <tr> + <td>{{SpecName('ES1')}}</td> + <td>{{Spec2('ES1')}}</td> + <td>Initiale Definition.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-4.3.11', 'null value')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-null-value', 'null value')}}</td> + <td>{{Spec2('ES6')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-null-value', 'null value')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browserkompatibilität">Browserkompatibilität</h2> + + + +<p>{{Compat("javascript.builtins.null")}}</p> + +<h2 id="See_also" name="See_also">Siehe auch</h2> + +<ul> + <li>{{jsxref("undefined")}}</li> + <li>{{jsxref("NaN")}}</li> +</ul> |