blob: b8fcd394436fac68a9906b212f1449730aba9db3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
---
title: Number.toInteger()
slug: Web/JavaScript/Referencia/Objectes_globals/Number/toInteger
translation_of: Archive/Web/JavaScript/Number.toInteger
---
<div>{{JSRef}} {{obsolete_header("33")}} {{non-standard_header}}</div>
<p>El mètode <strong><code>Number.toInteger()</code></strong> evaluava el valor passat com a paràmetre i el convertia en un nombre sencer, aquest mètode, però, ha sigut eliminat.</p>
<p>Si el valor és {{jsxref("NaN")}}, {{jsxref("null")}} o bé {{jsxref("undefined")}}, es retorna 0. Si el valor és <code>false</code>, es retorna 0 mentre que si el valor és <code>true</code>, es retorna 1.</p>
<h2 id="Sintaxi">Sintaxi</h2>
<pre class="syntaxbox"><code>Number.toInteger(<em>nombre</em>)</code></pre>
<h3 id="Paràmetres">Paràmetres</h3>
<dl>
<dt><code>nombre</code></dt>
<dd>El valor a convertir-se en un nombre sencer.</dd>
</dl>
<h2 id="Exemples">Exemples</h2>
<h3 id="Utilitzar_toInteger">Utilitzar <code>toInteger</code></h3>
<pre class="brush: js">Number.toInteger(0.1); // 0
Number.toInteger(1); // 1
Number.toInteger(Math.PI); // 3
Number.toInteger(null); // 0
</pre>
<h2 id="Especificacions">Especificacions</h2>
<p><code>Number.toInteger()</code> era part de l'esborrany de l'especificació de l'ECMAScript 6, però el 23 d'agost de 2013 es va eliminar a la revisió 17 de l'esborrany.</p>
<h2 id="Compatibilitat_amb_navegadors">Compatibilitat amb navegadors</h2>
<div>{{CompatibilityTable}}</div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Característica</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Suport bàsic</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}} [1]</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Característica</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Suport bàsic</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}} [1]</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
</tr>
</tbody>
</table>
</div>
<p>[1] Aquesta característica va estar suportada des del Firefox 16 al 32.</p>
<h2 id="Vegeu_també">Vegeu també</h2>
<ul>
<li>{{jsxref("Number")}}</li>
</ul>
|