1
00:00:02,290 --> 00:00:04,710
Now that we learned a lot about numbers and big 

2
00:00:04,720 --> 00:00:05,210
integer,

3
00:00:05,230 --> 00:00:11,200
before we move on to strings, let's have a look at the number and the math global object.

4
00:00:11,200 --> 00:00:16,390
We used some of the features of these objects already and now I just want to have a second look and

5
00:00:16,570 --> 00:00:18,220
walk you through the important ones,

6
00:00:18,220 --> 00:00:19,920
let's start with number.

7
00:00:19,930 --> 00:00:24,880
There we saw MAX_SAFE_INTEGER, MAX_VALUE, MIN_SAFE_INTEGER and MIN_VALUE,

8
00:00:25,000 --> 00:00:28,050
you also have negative and positive infinity.

9
00:00:28,060 --> 00:00:32,410
These are special values in Javascript which you also can just type like this

10
00:00:32,410 --> 00:00:36,580
by the way, infinity and -infinity

11
00:00:36,820 --> 00:00:43,180
and this is the value you for example get if you divide by zero, you'll not get an error which you might

12
00:00:43,180 --> 00:00:43,840
expect,

13
00:00:43,870 --> 00:00:49,930
instead you get infinity because it basically approximates the result you could say.

14
00:00:49,930 --> 00:00:56,440
So infinity is a special value you can get and you can also check for infinity in places where you need

15
00:00:56,450 --> 00:00:57,760
true or false,

16
00:00:57,760 --> 00:00:59,890
for that you've got the isFinite method,

17
00:00:59,950 --> 00:01:07,020
also on the number object but also available just on a global object to which you can pass a number

18
00:01:07,020 --> 00:01:08,490
to find out if this is finite,

19
00:01:08,490 --> 00:01:12,210
like an example of 10 is true or if it's infinite

20
00:01:12,210 --> 00:01:19,100
as an example of infinity because that is not finite and therefore, this returns false.

21
00:01:19,170 --> 00:01:21,670
So number isFinite can be useful,

22
00:01:21,750 --> 00:01:24,060
we also have isNaN there,

23
00:01:24,060 --> 00:01:28,140
we saw that earlier already, also exists as a global method.

24
00:01:28,260 --> 00:01:32,970
We got parseFloat and parseInt here which also exists globally though and therefore we don't really need

25
00:01:32,970 --> 00:01:33,480
that here

26
00:01:33,810 --> 00:01:36,810
and that's therefore basically it for the number object.

27
00:01:37,230 --> 00:01:39,900
More interesting than that is the math object,

28
00:01:39,900 --> 00:01:48,190
there you get various methods and constants or properties that help you with mathematical operations.

29
00:01:48,270 --> 00:01:56,790
You've got the value for the E number, for Pi if you need that in calculations, methods for calculating

30
00:01:56,790 --> 00:02:01,290
the square root, for working with the sin for example,

31
00:02:01,290 --> 00:02:03,210
also the power of method

32
00:02:03,210 --> 00:02:09,750
we saw a second ago in this module already, the abs method to give you an absolute number based on some

33
00:02:10,170 --> 00:02:16,020
number you pass in as an input and many more methods, like for example also the random method you

34
00:02:16,020 --> 00:02:19,530
already learned about which also can often be very convenient.

35
00:02:20,280 --> 00:02:24,630
I can only recommend that you scroll through the various methods you've got there, as you can see, there are

36
00:02:24,630 --> 00:02:30,780
a lot, of course the MDN docs are also a great place to learn all about them and whenever you have

37
00:02:30,780 --> 00:02:34,650
a mathematical operation you need to perform in your code,

38
00:02:34,710 --> 00:02:39,600
chances are that you don't need to reinvent the wheel and you don't need to write your own logic but

39
00:02:39,590 --> 00:02:44,820
that the math object has got you covered and provides the operation you want to perform.
