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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
---
title: Math.pow()
slug: Web/JavaScript/Reference/Global_Objects/Math/pow
translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow
---
<div>{{JSRef}}</div>
<p>La funzione <strong><code>Math.pow() </code></strong>restituisce la potenza della base che si desidera moltiplicare per se stessa a seconda del valore dell'esponenete, cioè <code>base<sup>esponente</sup></code>.</p>
<h2 id="Sintassi">Sintassi</h2>
<pre class="syntaxbox"><code>Math.pow(<var>base</var>, <var>esponente</var>)</code></pre>
<h3 id="Parametri">Parametri</h3>
<dl>
<dt><code>base</code></dt>
<dd>La basee del numero.</dd>
<dt><code>esponente</code></dt>
<dd>L'esponente usato per elevare la base.</dd>
</dl>
<h3 id="Valore_di_Ritorno">Valore di Ritorno</h3>
<p>Un numero che rappresenta la base elevata alla potenza dell'esponente.</p>
<h2 id="Descrizione">Descrizione</h2>
<p><code><font face="Open Sans, Arial, sans-serif">Siccome </font>pow()</code> è un metodo static di <code>Math</code>, lo usi sempre nella forma <code>Math.pow()</code>, piuttosto che come un metodo di un oggetto <code>Math</code> da te creato (<code>Math</code> non ha costruttori).</p>
<h2 id="Esempi">Esempi</h2>
<h3 id="Usando_Math.pow()">Usando <code>Math.pow()</code></h3>
<pre class="brush: js">// semplice
Math.pow(7, 2); // 49
Math.pow(7, 3); // 343
Math.pow(2, 10); // 1024
// esponenti fratti
Math.pow(4, 0.5); // 2 (radice quadrata di 4)
Math.pow(8, 1/3); // 2 (radice cubica di 8)
Math.pow(2, 0.5); // 1.4142135623730951 (radice quadrata di 2)
Math.pow(2, 1/3); // 1.2599210498948732 (radice cubica di 2)
// esponenti negativi
Math.pow(7, -2); // 0.02040816326530612 (1/49)
Math.pow(8, -1/3); // 0.5
// basi negative
Math.pow(-7, 2); // 49 (i quadrati son sempre positivi)
Math.pow(-7, 3); // -343 (i cubi possono essere negativi)
Math.pow(-7, 0.5); // NaN (i numeri negativi non hanno una quadrata reale)
// Siccome le radici "pari" e quelle "dispari" sono vicine tra loro,
// e i limiti della precisione numerica per i valori di tipo float,
// le basi negative con esponenti fratti ritornano sempre NaN
Math.pow(-7, 1/3); // NaN
</pre>
<h2 id="Specifiche_Tecniche">Specifiche Tecniche</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specificazione</th>
<th scope="col">Status</th>
<th scope="col">Commento</th>
</tr>
<tr>
<td>{{SpecName('ES1')}}</td>
<td>{{Spec2('ES1')}}</td>
<td>
<p>Definizione iniziale. Implementata in JavaScript 1.0.</p>
</td>
</tr>
<tr>
<td>{{SpecName('ES5.1', '#sec-15.8.2.13', 'Math.pow')}}</td>
<td>{{Spec2('ES5.1')}}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('ES6', '#sec-math.pow', 'Math.pow')}}</td>
<td>{{Spec2('ES6')}}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('ESDraft', '#sec-math.pow', 'Math.pow')}}</td>
<td>{{Spec2('ESDraft')}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="Compatiblità_Browser">Compatiblità Browser </h2>
<div>{{CompatibilityTable}}</div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</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>Basic support</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatVersionUnknown}}</td>
</tr>
</tbody>
</table>
</div>
<h2 id="Vedi_anche">Vedi anche</h2>
<ul>
<li>{{jsxref("Math.cbrt()")}}</li>
<li>{{jsxref("Math.exp()")}}</li>
<li>{{jsxref("Math.log()")}}</li>
<li>{{jsxref("Math.sqrt()")}}</li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation" title="Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value. The standard arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/).">Exponentiation operator</a> {{experimental_inline}}</li>
</ul>
|