I want to get the absolute value of a number in JavaScript. That is, drop the sign. I know mathematically I can do this by squaring the number then taking the square root, b
Here is a fast way to obtain the absolute value of a number. It's applicable on every language:
x = -25; console.log((x ^ (x >> 31)) - (x >> 31));