The sign() function of the Math object accepts an integer number and returns its sign.(positive, negative)
- If the given number is a positive integer then, this function returns +1.
- And, if the given number is a negative integer then, this function returns -1.
Syntax
Its Syntax is as follows
Math.sign();
Example
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var result = Math.sign(-128); document.write("Result: "+result); </script> </body> </html>
Output
Result: -1