1
00:00:02,600 --> 00:00:08,660
There also is another useful method for finding out whether is part of an array or not and that's the

2
00:00:08,660 --> 00:00:09,710
includes method,

3
00:00:09,710 --> 00:00:16,040
though it's also most useful for primitive values because it also just checks values like index of

4
00:00:16,040 --> 00:00:16,650
does.

5
00:00:17,570 --> 00:00:20,080
So just wanted to throw this in here real quick,

6
00:00:20,120 --> 00:00:30,910
we could for example check if test results includes a value of let's say 10.99, which it does.

7
00:00:31,080 --> 00:00:34,810
This will then return true or false and therefore includes is a great choice

8
00:00:34,820 --> 00:00:40,130
if you're not interested in the index and also not interested in the value but just want to know whether

9
00:00:40,130 --> 00:00:46,310
it's part of the array or not. Though it's important to keep in mind that index of will return -1

10
00:00:46,310 --> 00:00:48,600
if something wasn't found.

11
00:00:48,620 --> 00:00:56,670
So this is essentially the same here as running index of and comparing that to not being equal to

12
00:00:56,670 --> 00:00:57,450
-1

13
00:00:57,450 --> 00:01:01,090
because if that is not equal to -1, we know that it exists.

14
00:01:01,110 --> 00:01:06,300
If it is equal to -1, it does not exist but of course that's a bit shorter and say saves us this

15
00:01:06,300 --> 00:01:07,480
extra comparison

16
00:01:07,560 --> 00:01:13,080
so if you only are interested in knowing whether it's part or not, includes this nice to have for primitive

17
00:01:13,140 --> 00:01:13,730
values.

18
00:01:13,950 --> 00:01:17,790
So here if I reload, I see true twice because it is part of that array.
