From cb9e359a51c3249d8f5157db69d43fd413ddeda6 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:45:12 +0100 Subject: unslug ca: move --- .../reference/global_objects/math/hypot/index.html | 139 +++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 files/ca/web/javascript/reference/global_objects/math/hypot/index.html (limited to 'files/ca/web/javascript/reference/global_objects/math/hypot/index.html') diff --git a/files/ca/web/javascript/reference/global_objects/math/hypot/index.html b/files/ca/web/javascript/reference/global_objects/math/hypot/index.html new file mode 100644 index 0000000000..e29bb754f1 --- /dev/null +++ b/files/ca/web/javascript/reference/global_objects/math/hypot/index.html @@ -0,0 +1,139 @@ +--- +title: Math.hypot() +slug: Web/JavaScript/Referencia/Objectes_globals/Math/hypot +translation_of: Web/JavaScript/Reference/Global_Objects/Math/hypot +--- +
{{JSRef}}
+ +

La funció Math.hypot() retorna la rel quadrada de la suma dels quadrats dels seus arguments, és a dir:

+ +

Math.hypot(v1,v2,,vn)=i=1nvi2=v12+v22++vn2\mathtt{\operatorname{Math.hypot}(v_1, v_2, \dots, v_n)} = \sqrt{\sum_{i=1}^n v_i^2} = \sqrt{v_1^2 + v_2^2 + \dots + v_n^2}

+ +

Sintaxi

+ +
Math.hypot([valor1[, valor2[, ...]]])
+ +

Paràmetres

+ +
+
valor1, valor2, ...
+
Nombres.
+
+ +

Descripció

+ +

Com que que hypot() és un mètode estàtic de Math, sempre s'utilitza com a Math.hypot(), en comptes de com a mètode d'una instància de Math (Math no és un constructor).

+ +

Si no es passa cap argument, el resultat és +0.

+ +

Si al menys un dels arguments no pot ser convertit a nombre el resultat és {{jsxref("Global_Objects/NaN", "NaN")}}.

+ +

Quan se li passa només un argument, Math.hypot() retorna el mateix valor que retornaria Math.abs().

+ +

Exemples

+ +

Utilitzar Math.hypot()

+ +
Math.hypot(3, 4);        // 5
+Math.hypot(3, 4, 5);     // 7.0710678118654755
+Math.hypot();            // 0
+Math.hypot(NaN);         // NaN
+Math.hypot(3, 4, 'foo'); // NaN, +'foo' => NaN
+Math.hypot(3, 4, '5');   // 7.0710678118654755, +'5' => 5
+Math.hypot(-3);          // 3, el mateix que Math.abs(-3)
+
+ +

Polyfill

+ +

Aquest mètode pot emular-se mitjançant la funció següent:

+ +
Math.hypot = Math.hypot || function() {
+  var y = 0;
+  var length = arguments.length;
+
+  for (var i = 0; i < length; i++) {
+    if (arguments[i] === Infinity || arguments[i] === -Infinity) {
+      return Infinity;
+    }
+    y += arguments[i] * arguments[i];
+  }
+  return Math.sqrt(y);
+};
+
+ +

Especificacions

+ + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES6', '#sec-math.hypot', 'Math.hypot')}}{{Spec2('ES6')}}Definició inicial.
+ +

Compatibilitat amb navegadors

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatChrome("38")}}{{CompatGeckoDesktop("27")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("27")}}{{CompatNo}}{{CompatNo}}8
+
+ +

Vegeu també

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