Numbers are everywhere
Let's try to list out some programs that use a lot of numbers.
- POS Apps: in calculating the total price, price after discount, the given amount of cash, the amount of cash to be returned etc.
- Online quizes: in calculating total marks, percentages, percentiles etc.
- Animations: in moving, or a better word - transforming, objects. This includes translation, rotation, skew and alot of stuff.
- And you can think of many more
Number
and Math
objects
To work around with numbers in JavaScript we have two simple friend objects of ours - Number
and Math
. The Number
object provides with only a few methods specifically to help in rounding numbers whereas the Math
object has got a whole bucket full of useful properties and methods to choose from.
Using the Math
object we can calculate sin, cos, tan for angles in radians, convert these to degrees. We can calculate squares, square roots, absolute values and so much more that we can make our own functional calculator.
We will go over both these objects in a coming chapter - for now just remember their names so when we introduce them later you don't get surprised!