Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Samual Sam

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

Live Demo

<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

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.