Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Math.sign

//The Math.sign() function returns either a positive or negative +/- 1,
//indicating the sign of a number passed into the argument. If the number passed into 
//Math.sign() is 0, it will return a +/- 0. Note that if the number is positive,
//an explicit (+) will not be returned.

Math.sign(3);     //  1
Math.sign(-3);    // -1
Math.sign('-3');  // -1
Math.sign(0);     //  0
Math.sign(-0);    // -0
Math.sign(NaN);   // NaN
Math.sign('foo'); // NaN
Math.sign();      // NaN
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
3+2 =