aboutsummaryrefslogtreecommitdiff
path: root/files/pl/web/javascript/reference/global_objects/math/abs/index.html
diff options
context:
space:
mode:
authorFlorian Merz <me@fiji-flo.de>2021-02-11 14:49:24 +0100
committerFlorian Merz <me@fiji-flo.de>2021-02-11 14:49:24 +0100
commitde5c456ebded0e038adbf23db34cc290c8829180 (patch)
tree2819c07a177bb7ec5f419f3f6a14270d6bcd7fda /files/pl/web/javascript/reference/global_objects/math/abs/index.html
parent8260a606c143e6b55a467edf017a56bdcd6cba7e (diff)
downloadtranslated-content-de5c456ebded0e038adbf23db34cc290c8829180.tar.gz
translated-content-de5c456ebded0e038adbf23db34cc290c8829180.tar.bz2
translated-content-de5c456ebded0e038adbf23db34cc290c8829180.zip
unslug pl: move
Diffstat (limited to 'files/pl/web/javascript/reference/global_objects/math/abs/index.html')
-rw-r--r--files/pl/web/javascript/reference/global_objects/math/abs/index.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/files/pl/web/javascript/reference/global_objects/math/abs/index.html b/files/pl/web/javascript/reference/global_objects/math/abs/index.html
new file mode 100644
index 0000000000..c3b333a4ce
--- /dev/null
+++ b/files/pl/web/javascript/reference/global_objects/math/abs/index.html
@@ -0,0 +1,54 @@
+---
+title: Math.abs()
+slug: Web/JavaScript/Referencje/Obiekty/Math/abs
+tags:
+ - JavaScript
+ - Math
+ - Method
+translation_of: Web/JavaScript/Reference/Global_Objects/Math/abs
+---
+<p>{{JSRef}}</p>
+
+<h2 id="Podsumowanie" name="Podsumowanie">Podsumowanie</h2>
+
+<p>Zwraca wartość bezwzględną danej liczby.</p>
+
+<p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.abs</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mrow><mo stretchy="false">|</mo><mi>x</mi><mo stretchy="false">|</mo></mrow><mo>=</mo><mrow><mo>{</mo><mtable columnalign="left left"><mtr><mtd><mi>x</mi></mtd><mtd><mtext>if</mtext><mspace width="1em"></mspace><mi>x</mi><mo>&gt;</mo><mn>0</mn></mtd></mtr><mtr><mtd><mi>0</mi></mtd><mtd><mtext>if</mtext><mspace width="1em"></mspace><mi>x</mi><mo>=</mo><mn>0</mn></mtd></mtr><mtr><mtd><mo>-</mo><mi>x</mi></mtd><mtd><mtext>if</mtext><mspace width="1em"></mspace><mi>x</mi><mo>&lt;</mo><mn>0</mn></mtd></mtr></mtable></mrow></mrow><annotation encoding="TeX">{\mathtt{\operatorname{Math.abs}(x)}} = {|x|} = \begin{cases} x &amp; \text{if} \quad x \geq 0 \\ -x &amp; \text{if} \quad x &lt; 0 \end{cases} </annotation></semantics></math></p>
+
+<h2 id="Sk.C5.82adnia" name="Sk.C5.82adnia">Składnia</h2>
+
+<pre class="syntaxbox"><code>Math.abs(<var>x</var>)</code></pre>
+
+<h3 id="Parametry" name="Parametry">Parametry</h3>
+
+<dl>
+ <dt><code>x</code> </dt>
+ <dd>liczba.</dd>
+</dl>
+
+<h2 id="Opis" name="Opis">Opis</h2>
+
+<p>Ponieważ <code>abs</code> jest statyczną metodą obiektu {{jsxref("Math")}}, zawsze odwołujemy się do niej poprzez <code>Math.abs()</code>, a nie jak do metody instancji obiektu {{jsxref("Math")}} utworzonej przez użytkownika.</p>
+
+<h2 id="Przyk.C5.82ady" name="Przyk.C5.82ady">Przykłady</h2>
+
+<h3 id="Przyk.C5.82ad:_Zastosowanie_Math.abs" name="Przyk.C5.82ad:_Zastosowanie_Math.abs">Przykład: Zastosowanie <code>Math.abs()</code></h3>
+
+<p>Poniższa funkcja zwraca wartość bezwzględną zmiennej <code>x</code>:</p>
+
+<pre class="brush: js">Math.abs('-1'); // 1
+Math.abs(-2); // 2
+Math.abs(null); // 0
+Math.abs('string'); // NaN
+Math.abs(); // NaN
+</pre>
+
+<h2 id="Zobacz_tak.C5.BCe" name="Zobacz_tak.C5.BCe">Zobacz także</h2>
+
+<ul>
+ <li>{{jsxref("Math.ceil()")}}</li>
+ <li>{{jsxref("Math.floor()")}}</li>
+ <li>{{jsxref("Math.round()")}}</li>
+ <li>{{jsxref("Math.sign()")}} {{experimental_inline}}</li>
+ <li>{{jsxref("Math.trunc()")}} {{experimental_inline}}</li>
+</ul>