From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- .../reference/global_objects/math/pow/index.html | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 files/zh-tw/web/javascript/reference/global_objects/math/pow/index.html (limited to 'files/zh-tw/web/javascript/reference/global_objects/math/pow') diff --git a/files/zh-tw/web/javascript/reference/global_objects/math/pow/index.html b/files/zh-tw/web/javascript/reference/global_objects/math/pow/index.html new file mode 100644 index 0000000000..00ccb041ae --- /dev/null +++ b/files/zh-tw/web/javascript/reference/global_objects/math/pow/index.html @@ -0,0 +1,107 @@ +--- +title: Math.pow() +slug: Web/JavaScript/Reference/Global_Objects/Math/pow +tags: + - 次方 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow +--- +
{{JSRef}}
+ +

Math.pow() 函式回傳 baseexponent 次方(幂)值,也就是 baseexponent

+ +

語法

+ +
Math.pow(base, exponent)
+ +

參數

+ +
+
base
+
基數。
+
exponent
+
要乘上 base 幾次的指數。
+
+ +

回傳值

+ +

A number representing the given base taken to the power of the given exponent.

+ +

敘述

+ +

The Math.pow() function returns the base to the exponent power, that is, baseexponent, the base and the exponent are in decimal numeral system.

+ +

由於 pow()Math 的靜態方法,you always use it as Math.pow(), rather than as a method of a Math object you created(Math 並沒有建構子)。

+ +

示例

+ +

使用 Math.pow()

+ +
// simple
+Math.pow(7, 2);    // 49
+Math.pow(7, 3);    // 343
+Math.pow(2, 10);   // 1024
+// fractional exponents
+Math.pow(4, 0.5);  // 2 (4 的平方根)
+Math.pow(8, 1/3);  // 2 (8 的立方根)
+Math.pow(2, 0.5);  // 1.4142135623730951 (2 的平方根)
+Math.pow(2, 1/3);  // 1.2599210498948732 (2 的立方根)
+// signed exponents
+Math.pow(7, -2);   // 0.02040816326530612 (1/49)
+Math.pow(8, -1/3); // 0.5
+// signed bases
+Math.pow(-7, 2);   // 49 (負負得正,2次方都是正數)
+Math.pow(-7, 3);   // -343 (3次方有可能為負數)
+Math.pow(-7, 0.5); // NaN (負數沒辦法得出一個實數平方根)
+// due to "even" and "odd" roots laying close to each other,
+// and limits in the floating number precision,
+// negative bases with fractional exponents always return NaN
+Math.pow(-7, 1/3); // NaN
+
+ +

規範

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
規範狀態註解
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.13', 'Math.pow')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.pow', 'Math.pow')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.pow', 'Math.pow')}}{{Spec2('ESDraft')}}
+ +

瀏覽器相容性

+ + + +

{{Compat("javascript.builtins.Math.pow")}}

+ +

參見

+ + -- cgit v1.2.3-54-g00ecf