diff options
| author | julieng <julien.gattelier@gmail.com> | 2021-08-03 08:03:23 +0200 |
|---|---|---|
| committer | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-09-03 08:08:25 +0200 |
| commit | bf8e099b9c8b3c60d60b3712b4fc97b052c39887 (patch) | |
| tree | c101746d082c9581c94f5937519c7d0e2f4af8cb /files/fr/web/javascript/reference/global_objects/null | |
| parent | 844f5103992238c0c23203286dad16a466e89c97 (diff) | |
| download | translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.tar.gz translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.tar.bz2 translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.zip | |
convert content to md
Diffstat (limited to 'files/fr/web/javascript/reference/global_objects/null')
| -rw-r--r-- | files/fr/web/javascript/reference/global_objects/null/index.md | 88 |
1 files changed, 33 insertions, 55 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/null/index.md b/files/fr/web/javascript/reference/global_objects/null/index.md index fb9a228f19..265e06cd86 100644 --- a/files/fr/web/javascript/reference/global_objects/null/index.md +++ b/files/fr/web/javascript/reference/global_objects/null/index.md @@ -9,31 +9,34 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/null original_slug: Web/JavaScript/Reference/Objets_globaux/null --- -<div>{{jsSidebar("Objects")}}</div> +{{jsSidebar("Objects")}} -<p>La valeur <strong><code>null</code></strong> est un littéral JavaScript représentant la nullité au sens où aucune valeur pour l'objet n'est présente. C'est une des valeurs primitives de JavaScript.</p> +La valeur **`null`** est un littéral JavaScript représentant la nullité au sens où aucune valeur pour l'objet n'est présente. C'est une des valeurs primitives de JavaScript. -<div>{{EmbedInteractiveExample("pages/js/globalprops-null.html")}}</div> +{{EmbedInteractiveExample("pages/js/globalprops-null.html")}} -<h2 id="Syntaxe">Syntaxe</h2> +## Syntaxe -<pre class="syntaxbox">null</pre> + null -<h2 id="Description">Description</h2> +## Description -<p>La valeur <code>null</code> est un littéral (et non pas une propriété de l'objet global telle que {{jsxref("undefined")}}). Dans certaines API, <code>null</code> est souvent utilisé en valeur de retour lorsqu'un objet est attendu mais qu'aucun objet ne convient. Lors de tests d'égalité avec <code>null</code> ou <code>undefined</code>, il faut faire attention aux <a href="/fr/docs/Web/JavaScript/Les_différents_tests_d_égalité_comment_les_utiliser">différences entre les opérateurs d'égalité faible (==) et stricte (===)</a> (on aura une conversion de type avec le premier).</p> +La valeur `null` est un littéral (et non pas une propriété de l'objet global telle que {{jsxref("undefined")}}). Dans certaines API, `null` est souvent utilisé en valeur de retour lorsqu'un objet est attendu mais qu'aucun objet ne convient. Lors de tests d'égalité avec `null` ou `undefined`, il faut faire attention aux [différences entre les opérateurs d'égalité faible (==) et stricte (===)](/fr/docs/Web/JavaScript/Les_différents_tests_d_égalité_comment_les_utiliser) (on aura une conversion de type avec le premier). -<pre class="brush: js">// toto n'existe pas, n'a pas été défini et n'a jamais été initialisé +```js +// toto n'existe pas, n'a pas été défini et n'a jamais été initialisé toto; "ReferenceError: toto is not defined" // toto existe mais n'a ni type ni valeur var toto = null; -console.log(toto); // null</pre> +console.log(toto); // null +``` -<h3 id="Différence_entre_null_et_undefined">Différence entre <code>null</code> et <code>undefined</code></h3> +### Différence entre `null` et `undefined` -<pre class="brush: js">typeof null; // "object" (pas null pour des raisons historiques) +```js +typeof null; // "object" (pas null pour des raisons historiques) typeof undefined; // "undefined" null === undefined; // false null == undefined; // true @@ -42,47 +45,22 @@ null == null; // true !null; // true isNaN(1 + null); // false isNaN(1 + undefined); // true -</pre> - -<h2 id="Spécifications">Spécifications</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Spécification</th> - <th scope="col">État</th> - <th scope="col">Commentaires</th> - </tr> - <tr> - <td>{{SpecName('ES1')}}</td> - <td>{{Spec2('ES1')}}</td> - <td>Définition initiale.</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="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> - -<p>{{Compat("javascript.builtins.null")}}</p> - -<h2 id="Voir_aussi">Voir aussi</h2> - -<ul> - <li>{{jsxref("undefined")}}</li> - <li>{{jsxref("NaN")}}</li> -</ul> +``` + +## Spécifications + +| Spécification | État | Commentaires | +| ---------------------------------------------------------------------------- | ---------------------------- | -------------------- | +| {{SpecName('ES1')}} | {{Spec2('ES1')}} | Définition initiale. | +| {{SpecName('ES5.1', '#sec-4.3.11', 'null value')}} | {{Spec2('ES5.1')}} | | +| {{SpecName('ES6', '#sec-null-value', 'null value')}} | {{Spec2('ES6')}} | | +| {{SpecName('ESDraft', '#sec-null-value', 'null value')}} | {{Spec2('ESDraft')}} | | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.null")}} + +## Voir aussi + +- {{jsxref("undefined")}} +- {{jsxref("NaN")}} |
