JS Math Object

JavaScript Math Object

The Javascript Math object is used for performing mathematical calculations using properties and functions like: max, min, round, random, sin, cos, sqrt, log, ceil, abs, e, pi.

JavaScript Math Object

Example Max()

<script type="text/javascript">
<!--
var a = document.getElementById.innerHTML=Math.max(3,7);
document.write(a);
//-->
</script>

Result:

7

Example Min()

<script type="text/javascript">
<!--
var a = document.getElementById.innerHTML=Math.min(3,7);
document.write(a);
//-->
</script>

Result:

3

Example Round()

<script type="text/javascript">
<!--
var a = document.getElementById.innerHTML=Math.round(3.7);
document.write(a);
//-->
</script>

Result:

4