Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

Math.sign()

# The Math.sign() function returns either a positive or negative +/- 1, indicating the sign of a number passed into the argument


console.log(Math.sign(3));
// expected output: 1

console.log(Math.sign(-3));
// expected output: -1

console.log(Math.sign(0));
// expected output: 0

console.log(Math.sign('-3'));
// expected output: -1


A number representing the sign of the given argument:

If the argument is positive, returns 1.
If the argument is negative, returns -1.
If the argument is positive zero, returns 0.
If the argument is negative zero, returns -0.
Otherwise, NaN is returned.
Comment

javaScript Math.sign()

Math.sign(-4);
Math.sign(0);
Math.sign(4);
Comment

PREVIOUS NEXT
Code Example
Javascript :: added font to react native 
Javascript :: JavaScript next() Method 
Javascript :: module export in node js 
Javascript :: toastify react not working 
Javascript :: javascript slice string from character 
Javascript :: expresiones regulares javascript 
Javascript :: angular retry interceptor 
Javascript :: promise in javascript 
Javascript :: cancel an event in javascript 
Javascript :: create primary key in mongodb 
Javascript :: clear timeout in function js 
Javascript :: get image src width and height 
Javascript :: Run project in visual studio with iis express 
Javascript :: how to use if condition in jquery validation 
Javascript :: how to get data-target value in jquery 
Javascript :: js style 
Javascript :: next js redirect if not logged in 
Javascript :: var js 
Javascript :: javascript Example 1: Regular Expressions 
Javascript :: array some 
Javascript :: how to get the last two characters of a string in javascript 
Javascript :: datatable highlight cells based on their content 
Javascript :: export module in es6 
Javascript :: puppeteer 
Javascript :: for in javascript 
Javascript :: on hover display block jquery 
Javascript :: react native dynamically update flatlist data 
Javascript :: Uncaught TypeError: theme.spacing is not a function 
Javascript :: how to start node server 
Javascript :: string to uppercase 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =