You must be wondering by now, are these the only mathematical operations supported by JavaScript?
The answer is no.
JavaScript supports an abundance of other operations, however, they are not provided using simple operators. These can be accessed through the JavaScript's built-in Math
object. Simply use Math.<operator-name>
and you can access more maths operators from there such as square root, floor and ceiling functions among many others. You will have to be careful with the spellings of these operators as they are built-in within the programming language.
Let's see some examples.
JAVASCRIPT
1var x = Math.floor(4.5);
2console.log(x); // prints 4
3
4var y = Math.sqrt(100);
5console.log(y); //prints 10
A comprehensive list of all operations provided by the JavaScript Math module is available here.