1 00:00:00,610 --> 00:00:04,840 Let me show you just one more thing about forEach before we move on. 2 00:00:04,840 --> 00:00:09,210 Let's go the MDN documentation page for the forEach method. 3 00:00:09,210 --> 00:00:13,130 You can see here that the callback in forEach actually accepts some other 4 00:00:13,130 --> 00:00:17,000 parameters besides the array element we've been using. 5 00:00:17,000 --> 00:00:21,280 The second parameter will hold the index of the current element. 6 00:00:21,280 --> 00:00:24,030 So if the current value is the first element, for 7 00:00:24,030 --> 00:00:27,450 example, the index value will be zero. 8 00:00:27,450 --> 00:00:31,470 If it's the second element the index will be one, and so on. 9 00:00:31,470 --> 00:00:35,060 If your code relies on the position of the elements in an array, 10 00:00:35,060 --> 00:00:37,120 this can be helpful to know. 11 00:00:37,120 --> 00:00:41,380 The third parameter will hold the whole array itself. 12 00:00:41,380 --> 00:00:46,010 Neither of these parameters are useful for most applications, but I just wanted to 13 00:00:46,010 --> 00:00:50,740 make sure you knew about them in case you see examples where they're used. 14 00:00:50,740 --> 00:00:54,280 I'll just demonstrate the index property quickly. 15 00:00:54,280 --> 00:00:59,470 Let's say we want to print all the names in this array here, and 16 00:00:59,470 --> 00:01:01,350 we want to number them as well. 17 00:01:03,220 --> 00:01:06,740 I'll just add a second parameter, the index, to this callback. 18 00:01:14,078 --> 00:01:18,449 I'll replace this function body with a call to console.log, 19 00:01:18,449 --> 00:01:21,550 passing in a template literal. 20 00:01:21,550 --> 00:01:26,010 Since arrays are zero-based I'm adding 1 to the index, and 21 00:01:26,010 --> 00:01:28,080 putting a parenthesis, and then the name. 22 00:01:29,100 --> 00:01:32,150 I'll delete this console.log below the loop as well. 23 00:01:34,602 --> 00:01:40,236 Now when I run this code, You 24 00:01:40,236 --> 00:01:44,160 can see the index number has been accessed to provide these numbers. 25 00:01:45,630 --> 00:01:47,480 One more thing, the index and 26 00:01:47,480 --> 00:01:52,940 array parameters are available on all of the array methods we cover in this course. 27 00:01:52,940 --> 00:01:56,350 If you ever have questions about what parameters methods accept, 28 00:01:56,350 --> 00:01:59,115 I recommend checking out MDN for details. 29 00:01:59,115 --> 00:02:02,960 I've created some additional practice for you after this video.