diff options
| author | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:36:08 +0100 |
|---|---|---|
| committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:36:08 +0100 |
| commit | 39f2114f9797eb51994966c6bb8ff1814c9a4da8 (patch) | |
| tree | 66dbd9c921f56e440f8816ed29ac23682a1ac4ef /files/fr/web/javascript/reference/global_objects/number/parsefloat | |
| parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
| download | translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.tar.gz translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.tar.bz2 translated-content-39f2114f9797eb51994966c6bb8ff1814c9a4da8.zip | |
unslug fr: move
Diffstat (limited to 'files/fr/web/javascript/reference/global_objects/number/parsefloat')
| -rw-r--r-- | files/fr/web/javascript/reference/global_objects/number/parsefloat/index.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/number/parsefloat/index.html b/files/fr/web/javascript/reference/global_objects/number/parsefloat/index.html new file mode 100644 index 0000000000..85059f92a3 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/number/parsefloat/index.html @@ -0,0 +1,84 @@ +--- +title: Number.parseFloat() +slug: Web/JavaScript/Reference/Objets_globaux/Number/parseFloat +tags: + - ECMAScript 2015 + - JavaScript + - Méthode + - Number + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseFloat +--- +<div>{{JSRef}}</div> + +<p>La méthode <strong><code>Number.parseFloat()</code></strong> analyse et convertit une chaîne de caractères en un nombre flottant. Cette méthode possède un comportement identique à {{jsxref("parseFloat")}} et fait partie d'ECMAScript 2015 (dans le but de « modulariser » les méthodes globales).</p> + +<div>{{EmbedInteractiveExample("pages/js/number-parsefloat.html")}}</div> + +<p class="hidden">Le code source de cet exemple interactif est disponible dans un dépôt GitHub. Si vous souhaitez contribuer à ces exemples, n'hésitez pas à cloner <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> et à envoyer une <em>pull request</em> !</p> + +<h2 id="Syntaxe">Syntaxe</h2> + +<pre class="syntaxbox">Number.parseFloat(chaîne)</pre> + +<h3 id="Paramètres">Paramètres</h3> + +<dl> + <dt><code><var>chaîne</var></code></dt> + <dd>Une chaîne de caractères qu'on souhaite convertir en nombre flottant.</dd> +</dl> + +<h3 id="Valeur_de_retour">Valeur de retour</h3> + +<p>Un nombre flottant obtenu à partir de l'analyse de la chaîne de caractères passée en argument. Si le premier caractère de la chaîne ne peut pas être converti en un nombre, la valeur {{jsxref("NaN")}} sera renvoyée.</p> + +<h2 id="Description">Description</h2> + +<p>Cette méthode possède les mêmes fonctionnalités que la fonction globale {{jsxref("parseFloat", "parseFloat()")}} :</p> + +<pre>Number.parseFloat === parseFloat; // true +</pre> + +<p>Cette méthode fait partie d'ECMAScript 2015 et notamment de la modularisation de certaines fonctions globales. Pour plus de détails et d'exemples, voir {{jsxref("parseFloat", "parseFloat()")}}.</p> + +<h2 id="Prothèse_d'émulation_(polyfill)">Prothèse d'émulation (<em>polyfill</em>)</h2> + +<pre class="brush: js">if (Number.parseFloat === undefined) { + Number.parseFloat = parseFloat; +} +</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('ES2015', '#sec-number.parsefloat', 'Number.parseFloat')}}</td> + <td>{{Spec2('ES2015')}}</td> + <td>Définition initiale.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-number.parsefloat', 'Number.parseFloat')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> + +<p class="hidden">Le tableau de compatibilité de cette page a été généré à partir de données structurées. Si vous souhaitez contribuer à ces données, n'hésitez pas à envoyer une <em>pull request</em> sur <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>.</p> + +<p>{{Compat("javascript.builtins.Number.parseFloat")}}</p> + +<h2 id="Voir_aussi">Voir aussi</h2> + +<ul> + <li>L'objet {{jsxref("Number")}} auquel appartient cette fonction.</li> + <li>La méthode globale {{jsxref("parseFloat")}}.</li> +</ul> |
