Number.sign() in javascript
More elegant version of fast solution:
var sign = number?number<0?-1:1:0
Dividing the number by its absolute value also gives its sign. Using the short-circuiting logical AND operator allows us to special-case 0
so we don't end up dividing by it:
var sign = number && number / Math.abs(number);