aboutsummaryrefslogtreecommitdiff
path: root/files/fr/glossary/function
diff options
context:
space:
mode:
authorSphinxKnight <SphinxKnight@users.noreply.github.com>2021-11-15 19:39:35 +0100
committerGitHub <noreply@github.com>2021-11-15 19:39:35 +0100
commit6f6e297fbfa7867b1f42c4245df20f4282b3b083 (patch)
treee602e617243ed4427e45c30554939818bfba8d6e /files/fr/glossary/function
parent34d315396ca29d7ef51ecc27eeeeeb275e9b0ba9 (diff)
downloadtranslated-content-6f6e297fbfa7867b1f42c4245df20f4282b3b083.tar.gz
translated-content-6f6e297fbfa7867b1f42c4245df20f4282b3b083.tar.bz2
translated-content-6f6e297fbfa7867b1f42c4245df20f4282b3b083.zip
Prepare Glossary section for Markdown conversion (#2971)
* Remove seoSummary and summary classes * Fix hidden blocks / code samples * Remove span cruft * Remove <font> and <style .. font..> * Remove notranslate * Remove id other than in headings * Fix pre blocks and remove style * Fix other report one offs and remove absolute urls * Remove external classes * Fixing images url
Diffstat (limited to 'files/fr/glossary/function')
-rw-r--r--files/fr/glossary/function/index.html86
1 files changed, 43 insertions, 43 deletions
diff --git a/files/fr/glossary/function/index.html b/files/fr/glossary/function/index.html
index ae80d37e95..efcce3ca49 100644
--- a/files/fr/glossary/function/index.html
+++ b/files/fr/glossary/function/index.html
@@ -19,71 +19,71 @@ original_slug: Glossaire/Fonction
<p>Une <strong>fonction anonyme</strong> est une fonction sans nom de fonction :</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span><span class="punctuation token">}</span><span class="punctuation token">;</span>
-<span class="comment token">// ou en utilisant la notation de flèche de ECMAScript 2015</span>
-<span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="operator token">=</span><span class="operator token">&gt;</span> <span class="punctuation token">{</span><span class="punctuation token">}</span><span class="punctuation token">;</span></code></pre>
+<pre class="brush: js">function () {};
+// ou en utilisant la notation de flèche de ECMAScript 2015
+() =&gt; {};</pre>
<p>Une <strong>fonction nommée</strong> est une fonction avec un nom de fonction :</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">foo</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span><span class="punctuation token">}</span><span class="punctuation token">;</span>
-<span class="comment token">// ou en utilisant la notation de flèche de ECMAScript 2015</span>
-<span class="keyword token">const</span> foo <span class="operator token">=</span> <span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="operator token">=</span><span class="operator token">&gt;</span> <span class="punctuation token">{</span><span class="punctuation token">}</span><span class="punctuation token">;</span></code></pre>
+<pre class="brush: js">function foo() {};
+// ou en utilisant la notation de flèche de ECMAScript 2015
+const foo = () =&gt; {};</pre>
<p>Une <strong>fonction imbriquée (ou fonction interne)</strong> est une fonction à l'intérieur d'une autre fonction (<em><code>square</code></em> dans l'exemple suivant). Une <strong>fonction externe</strong> est une fonction qui contient une fonction (<em><code>addSquares</code></em> dans l'exemple suivant) :</p>
<dl>
</dl>
-<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">addSquares</span><span class="punctuation token">(</span>a<span class="punctuation token">,</span>b<span class="punctuation token">)</span> <span class="punctuation token">{</span>
- <span class="keyword token">function</span> <span class="function token">square</span><span class="punctuation token">(</span>x<span class="punctuation token">)</span> <span class="punctuation token">{</span>
- <span class="keyword token">return</span> x <span class="operator token">*</span> x<span class="punctuation token">;</span>
- <span class="punctuation token">}</span>
- <span class="keyword token">return</span> <span class="function token">square</span><span class="punctuation token">(</span>a<span class="punctuation token">)</span> <span class="operator token">+</span> <span class="function token">square</span><span class="punctuation token">(</span>b<span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span><span class="punctuation token">;</span>
-<span class="comment token">//En utilisant la notation de flèche de ECMAScript 2015</span>
-<span class="keyword token">const</span> addSquares <span class="operator token">=</span> <span class="punctuation token">(</span>a<span class="punctuation token">,</span>b<span class="punctuation token">)</span> <span class="operator token">=</span><span class="operator token">&gt;</span> <span class="punctuation token">{</span>
- <span class="keyword token">const</span> square <span class="operator token">=</span> x <span class="operator token">=</span><span class="operator token">&gt;</span> x<span class="operator token">*</span>x<span class="punctuation token">;</span>
- <span class="keyword token">return</span> <span class="function token">square</span><span class="punctuation token">(</span>a<span class="punctuation token">)</span> <span class="operator token">+</span> <span class="function token">square</span><span class="punctuation token">(</span>b<span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span><span class="punctuation token">;</span></code></pre>
+<pre class="brush: js">function addSquares(a,b) {
+ function square(x) {
+ return x * x;
+ }
+ return square(a) + square(b);
+};
+//En utilisant la notation de flèche de ECMAScript 2015
+const addSquares = (a,b) =&gt; {
+ const square = x =&gt; x*x;
+ return square(a) + square(b);
+};</pre>
<p>Une <strong>fonction récursive</strong> est une fonction qui fait appel à elle-même. Voir {{Glossary("Recursion","récursion")}}.</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">loop</span><span class="punctuation token">(</span>x<span class="punctuation token">)</span> <span class="punctuation token">{</span>
- <span class="keyword token">if</span> <span class="punctuation token">(</span>x <span class="operator token">&gt;=</span> <span class="number token">10</span><span class="punctuation token">)</span>
- <span class="keyword token">return</span><span class="punctuation token">;</span>
- <span class="function token">loop</span><span class="punctuation token">(</span>x <span class="operator token">+</span> <span class="number token">1</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span><span class="punctuation token">;</span>
-<span class="comment token">//En utilisant la notation de flèche de ECMAScript 2015</span>
-<span class="keyword token">const</span> loop <span class="operator token">=</span> x <span class="operator token">=</span><span class="operator token">&gt;</span> <span class="punctuation token">{</span>
- <span class="keyword token">if</span> <span class="punctuation token">(</span>x <span class="operator token">&gt;=</span> <span class="number token">10</span><span class="punctuation token">)</span>
- <span class="keyword token">return</span><span class="punctuation token">;</span>
- <span class="function token">loop</span><span class="punctuation token">(</span>x <span class="operator token">+</span> <span class="number token">1</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span><span class="punctuation token">;</span></code></pre>
-
-<p><span id="result_box" lang="fr"><span>Une <strong>expression de fonction invoquée immédiatement</strong> (IIFE) est une fonction appelée directement après le chargement de la fonction dans le compilateur du navigateur.</span> <span>La façon d'identifier une IIFE est de localiser les parenthèses gauche et droite supplémentaires à la fin de la déclaration de la fonction.</span></span></p>
-
-<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="comment token">// Erreur (https://en.wikipedia.org/wiki/Immediately-invoked_function_expression)</span>
-<span class="comment token">/*
+<pre class="brush: js">function loop(x) {
+ if (x &gt;= 10)
+ return;
+ loop(x + 1);
+};
+//En utilisant la notation de flèche de ECMAScript 2015
+const loop = x =&gt; {
+ if (x &gt;= 10)
+ return;
+ loop(x + 1);
+};</pre>
+
+<p>Une <strong>expression de fonction invoquée immédiatement</strong> (IIFE) est une fonction appelée directement après le chargement de la fonction dans le compilateur du navigateur. La façon d'identifier une IIFE est de localiser les parenthèses gauche et droite supplémentaires à la fin de la déclaration de la fonction.</p>
+
+<pre class="brush: js">// Erreur (https://en.wikipedia.org/wiki/Immediately-invoked_function_expression)
+/*
​function foo() {
console.log('Hello Foo');
}();
-*/</span>
+*/
-<span class="punctuation token">(</span><span class="keyword token">function</span> <span class="function token">foo</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
- console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Hello Foo"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
+(function foo() {
+ console.log("Hello Foo");
+}());
-<span class="punctuation token">(</span><span class="keyword token">function</span> <span class="function token">food</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
- console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"Hello Food"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre>
+(function food() {
+ console.log("Hello Food");
+})();</pre>
-<p><span id="result_box" lang="fr"><span>Si vous souhaitez en savoir plus sur les IIFE, consultez la page suivante sur Wikipedia : <a href="https://fr.wikipedia.org/wiki/JavaScript#Expressions_de_fonctions_imm%C3%A9diatement_invoqu%C3%A9es">Expression de la fonction immédiatement invoquée</a></span></span></p>
+<p>Si vous souhaitez en savoir plus sur les IIFE, consultez la page suivante sur Wikipedia : <a href="https://fr.wikipedia.org/wiki/JavaScript#Expressions_de_fonctions_imm%C3%A9diatement_invoqu%C3%A9es">Expression de la fonction immédiatement invoquée</a></p>
<h2 id="En_apprendre_plus">En apprendre plus</h2>
<h3 id="Informations_Techniques">Informations Techniques</h3>
<ul>
- <li><a href="https://developer.mozilla.org/fr/docs/Web/JavaScript/Guide/Fonctions" title="en-US/docs/Web/JavaScript/Guide/Functions">Les Fonctions</a> en JavaScript sur MDN</li>
- <li><a href="https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Fonctions/Fonctions_fl%C3%A9ch%C3%A9es">Fonctions fléchées</a></li>
+ <li><a href="/fr/docs/Web/JavaScript/Guide/Fonctions">Les Fonctions</a> en JavaScript sur MDN</li>
+ <li><a href="/fr/docs/Web/JavaScript/Reference/Fonctions/Fonctions_fl%C3%A9ch%C3%A9es">Fonctions fléchées</a></li>
</ul>