Here you can find a number of examples on Java Script.Please find the various kinds of examples listed on the right side of this site. If you don't find anything on Java Script then please write to us or leave a commnet. We are pleased to help and find the solution of your problem.

Javascript: ABS Function



abs function returns the absolute of a number.

Syntax

abs(A Number)


Description

Because abs is a static method of Math, you always use it as Math.abs(), rather than as a method of a Math object you created.



<html>
<head>
<title>Math.abs function</title>

<script language="javascript">
document.write("Math.abs(-4564) = " + Math.abs(-4564) + "<br>");
document.write("Math.abs(-5896.56) = " + Math.abs(-5896.56));
</script>

</head>
</html>



OUTPUT

Math.abs(-4564) = 4564
Math.abs(-5896.56) = 5896.56

No comments:

Post a Comment

Google