aboutsummaryrefslogtreecommitdiff
path: root/files/id/web/javascript/reference/global_objects/math/max/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/id/web/javascript/reference/global_objects/math/max/index.html')
-rw-r--r--files/id/web/javascript/reference/global_objects/math/max/index.html144
1 files changed, 144 insertions, 0 deletions
diff --git a/files/id/web/javascript/reference/global_objects/math/max/index.html b/files/id/web/javascript/reference/global_objects/math/max/index.html
new file mode 100644
index 0000000000..aeb1b207ce
--- /dev/null
+++ b/files/id/web/javascript/reference/global_objects/math/max/index.html
@@ -0,0 +1,144 @@
+---
+title: Math.max()
+slug: Web/JavaScript/Reference/Global_Objects/Math/max
+tags:
+ - JavaScript
+ - Math
+ - Method
+ - Reference
+translation_of: Web/JavaScript/Reference/Global_Objects/Math/max
+---
+<div>{{JSRef}}</div>
+
+<p>Fungsi <strong><code>Math.max()</code></strong> mengembalikan nilai terbesar dari zero atau lebih besar.</p>
+
+<h2 id="Sintaks">Sintaks</h2>
+
+<pre class="syntaxbox"><code>Math.max([<var>value1</var>[, <var>value2</var>[, ...]]])</code></pre>
+
+<h3 id="Parameter">Parameter</h3>
+
+<dl>
+ <dt><code>value1, value2, ...</code></dt>
+ <dd>Nomor.</dd>
+</dl>
+
+<h2 id="Deskripsi">Deskripsi</h2>
+
+<p>Karena <code>max()</code> merupakan method static dari <code>Math</code>, anda perlu menggunakan <code>Math.max()</code>, daripada sebagai method dari objek <code>Math</code> yang anda buat (<code>Math</code> bukan constructor).</p>
+
+<p>Jika tidak diberi argumen, hasilnya akan -{{jsxref("Infinity")}}.</p>
+
+<p>Jika setidaknya satu argumen tidak dapat dikonversi ke angka, maka hasilnya {{jsxref("NaN")}}.</p>
+
+<h2 id="Contoh">Contoh</h2>
+
+<h3 id="Penggunaan_Math.max()">Penggunaan <code>Math.max()</code></h3>
+
+<pre class="brush: js">Math.max(10, 20); // 20
+Math.max(-10, -20); // -10
+Math.max(-10, 20); // 20
+</pre>
+
+<p>Pada contoh menggunakan fungsi {{jsxref("Function.prototype.apply()")}} untuk mencari nilai elemen maksimum pada sebuah numeric array. <code>getMaxOfArray([1, 2, 3])</code> sama halnya dengan <code>Math.max(1, 2, 3)</code>, tapi anda bisa menggunakan <code>getMaxOfArray()</code> pada programmatikal pembuatan array untuk semua ukuran.</p>
+
+<pre class="brush: js">function getMaxOfArray(numArray) {
+ return Math.max.apply(null, numArray);
+}
+</pre>
+
+<p>Atau dengan {{jsxref("Operators/Spread_operator", "spread operator")}} baru, mencari nilai terbesar menjadi lebih mudah.</p>
+
+<pre class="brush: js">var arr = [1, 2, 3];
+var max = Math.max(...arr);
+</pre>
+
+<h2 id="Spesifikasi">Spesifikasi</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Spesifikasi</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES1')}}</td>
+ <td>{{Spec2('ES1')}}</td>
+ <td>Initial definition. Implemented in JavaScript 1.0.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.8.2.11', 'Math.max')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-math.max', 'Math.max')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-math.max', 'Math.max')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Kompabilitas_Browser">Kompabilitas 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="Lihat_juga">Lihat juga</h2>
+
+<ul>
+ <li>{{jsxref("Math.min()")}}</li>
+</ul>