aboutsummaryrefslogtreecommitdiff
path: root/files/fr/glossary/truthy
diff options
context:
space:
mode:
Diffstat (limited to 'files/fr/glossary/truthy')
-rw-r--r--files/fr/glossary/truthy/index.html36
1 files changed, 36 insertions, 0 deletions
diff --git a/files/fr/glossary/truthy/index.html b/files/fr/glossary/truthy/index.html
new file mode 100644
index 0000000000..62ed641a6b
--- /dev/null
+++ b/files/fr/glossary/truthy/index.html
@@ -0,0 +1,36 @@
+---
+title: Truthy
+slug: Glossaire/Truthy
+tags:
+ - Glossaire
+ - JavaScript
+ - Programmation
+translation_of: Glossary/Truthy
+---
+<p>En {{Glossary("JavaScript")}}, une valeur <code>truthy</code> est une valeur qui est considérée comme vraie quand elle est évaluée dans un contexte {{Glossary("Boolean","booléen")}} . Toutes les valeurs sont <code>truthy</code> sauf si elles sont definies comme {{Glossary("Falsy","falsy")}} (c'est-à-dire, sauf pour <code>false</code>, 0, "", <code>null</code>, <code>undefined</code>, et <code>NaN</code>).</p>
+
+<p><br>
+ {{Glossary("JavaScript")}} utilise la {{Glossary("Type_Conversion", "contrainte")}} de type dans un contexte booléen.</p>
+
+<p><br>
+ Exemples de valeurs truthy en JavaScript (qui seront considérées comme vraies, ce qui exécutera le bloc if):</p>
+
+<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">if</span> <span class="punctuation token">(</span><span class="keyword token">true</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="punctuation token">{</span><span class="punctuation token">}</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="punctuation token">[</span><span class="punctuation token">]</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="number token">42</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="string token">"foo"</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="keyword token">new</span> <span class="class-name token">Date</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="operator token">-</span><span class="number token">42</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="number token">3.14</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="operator token">-</span><span class="number token">3.14</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="number token">Infinity</span><span class="punctuation token">)</span>
+<span class="keyword token">if</span> <span class="punctuation token">(</span><span class="operator token">-</span><span class="number token">Infinity</span><span class="punctuation token">)</span></code></pre>
+
+<h2 id="Voir_aussi">Voir aussi </h2>
+
+<ul>
+ <li>{{Glossary("Falsy")}}</li>
+ <li>{{Glossary("Type_Conversion", "Contrainte")}}</li>
+ <li>{{Glossary("Boolean","Booléen")}}</li>
+</ul>