From 48775b07d0867f298e78553cde9b5fbafc03549f Mon Sep 17 00:00:00 2001 From: Tomoyuki Hata <7702653+hata6502@users.noreply.github.com> Date: Tue, 25 Jan 2022 11:36:09 +0900 Subject: Fix Math.max() initial value to -Infinity --- files/de/web/javascript/reference/global_objects/math/max/index.html | 2 +- files/ja/web/javascript/reference/global_objects/math/max/index.html | 2 +- files/ko/web/javascript/reference/global_objects/math/max/index.html | 2 +- files/pt-br/web/javascript/reference/global_objects/math/max/index.html | 2 +- files/zh-tw/web/javascript/reference/global_objects/math/max/index.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'files') diff --git a/files/de/web/javascript/reference/global_objects/math/max/index.html b/files/de/web/javascript/reference/global_objects/math/max/index.html index 426bf6abad..15d0981aa1 100644 --- a/files/de/web/javascript/reference/global_objects/math/max/index.html +++ b/files/de/web/javascript/reference/global_objects/math/max/index.html @@ -55,7 +55,7 @@ Math.max(-10, 20); // 20
var arr = [1, 2, 3];
 var max = arr.reduce(function(a, b) {
   return Math.max(a, b);
-});
+}, -Infinity);
 

Die folgende Funktion benutzt {{jsxref("Function.prototype.apply()")}}, um den maximalen Wert eines numerischen Arrays zu finden. getMaxOfArray([1, 2, 3]) entspricht Math.max(1, 2, 3), aber getMaxOfArray() kann programmatisch erstellte Arrays jeder Art annehmen.

diff --git a/files/ja/web/javascript/reference/global_objects/math/max/index.html b/files/ja/web/javascript/reference/global_objects/math/max/index.html index e650c30f15..afd2433e13 100644 --- a/files/ja/web/javascript/reference/global_objects/math/max/index.html +++ b/files/ja/web/javascript/reference/global_objects/math/max/index.html @@ -55,7 +55,7 @@ Math.max(-10, 20); // 20
var arr = [1,2,3];
 var max = arr.reduce(function(a, b) {
     return Math.max(a, b);
-});
+}, -Infinity);
 

次の関数では {{jsxref("Function.prototype.apply()")}} を使用して配列の最大値を取得します。 getMaxOfArray([1, 2, 3])Math.max(1, 2, 3) と同等ですが、 getMaxOfArray() はプログラム的に構築された配列に使用することができます。これは比較的要素が少ない配列に対して使用してください。

diff --git a/files/ko/web/javascript/reference/global_objects/math/max/index.html b/files/ko/web/javascript/reference/global_objects/math/max/index.html index 439aebe905..a90570b4c4 100644 --- a/files/ko/web/javascript/reference/global_objects/math/max/index.html +++ b/files/ko/web/javascript/reference/global_objects/math/max/index.html @@ -70,7 +70,7 @@ Math.max(-10, 20); // 20
var arr = [1,2,3];
 var max = arr.reduce(function(a, b) {
     return Math.max(a, b);
-});
+}, -Infinity);
 

다음 함수는 {{jsxref ( "Function.prototype.apply ()")}}을 사용하여 숫자 배열에서 최대 요소를 찾습니다. getMaxOfArray([1, 2, 3])는 diff --git a/files/pt-br/web/javascript/reference/global_objects/math/max/index.html b/files/pt-br/web/javascript/reference/global_objects/math/max/index.html index b28723014f..b294467920 100644 --- a/files/pt-br/web/javascript/reference/global_objects/math/max/index.html +++ b/files/pt-br/web/javascript/reference/global_objects/math/max/index.html @@ -52,7 +52,7 @@ Math.max(-10, 20); // 20

var arr = [1, 2, 3];
 var max = arr.reduce(function(a, b) {
   return Math.max(a, b);
-});
+}, -Infinity);

A função a seguir utiliza {{jsxref("Function.prototype.apply()")}} para encontrar o elemento de maior valor dentro do array. getMaxOfArray([1,2,3]) é equivalente a Math.max(1, 2, 3), mas você pode usar getMaxOfArray  em arrays construídos programaticamente e o ideal é utilizá-la somente em arrays com relativamente poucos elementos.

diff --git a/files/zh-tw/web/javascript/reference/global_objects/math/max/index.html b/files/zh-tw/web/javascript/reference/global_objects/math/max/index.html index d334c6bc02..a3e994c734 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/math/max/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/math/max/index.html @@ -55,7 +55,7 @@ Math.max(-10, 20); // 20
var arr = [1,2,3];
 var max = arr.reduce(function(a, b) {
     return Math.max(a, b);
-});
+}, -Infinity);
 

The following function uses {{jsxref("Function.prototype.apply()")}} to get the maximum of an array. getMaxOfArray([1, 2, 3]) is equivalent to Math.max(1, 2, 3), but you can use getMaxOfArray() on programmatically constructed arrays. This should only be used for arrays with relatively few elements.

-- cgit v1.2.3-54-g00ecf