This is an old question but it has a lot of views so I think that is important to update it.
ECMAScript 6 brought the function Math.sign()
, which returns the sign of a number (1 if it's positive, -1 if it's negative) or NaN if it is not a number. Reference
You could use it as:
var number = 1;
if(Math.sign(number) === 1){
alert("I'm positive");
}else if(Math.sign(number) === -1){
alert("I'm negative");
}else{
alert("I'm not a number");
}