JavaScript array methods in 5 minutes!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello for the past few days we were trying to deal with some problems on code Wars regarding our race so I decided that let's H to the code and see what methods we can use on our [Music] race so we are in Visual Studio code and let's create ourselves some basic array 1 2 3 4 5 and let's do some methods on it so the first method would be array. push push will add a new element to the array so let's console log let's console log it and let's do Noe array. JS and we have a 10 at the last element another method we can use is pop pop removes the last element and give it it back so let's also console lock console loog elements and let to note array so we are getting 1 2 3 four and five five in return because that's our input array another method we can use would be a map method method map method goes through each element of the array and does some kind of operation on that so we can let's say multiply every element by two and as you can see it's done another method we can use would be filter it also goes to each individual element and then tries to match them so let's say we want every element which is higher than three and we are getting four and five another method we can use is the reduce method reduce is very useful for summing up the arrays so we will give here a total and current element and here we can do a total Plus equals current and then we need to give the initial value of that and if we will console log the sum we'll get 15 so 5 9 12 14 15 let's go right now to find method so find method will give us the first matching elements so let's say we want element equal four or or maybe more than four when we will get that back we should receive five oh error okay sorry guys a little bit of debugging yeah that's it another method we can go through would be a maybe sum sum goes through all of the elements and it will return actually a Boolean value so let's say call it like is is Boolean and here will be whatever we want to check for so let's maybe do if any of the elements in the array is larger than three and if we console lock this is bullan we should get true because four and five will be will be larger another method you can use like this is every this checks if every element in the array matches the pattern we gave so in this particular example we will get false and that's actually some some of the basic array methods you can use see you next time
Info
Channel: DEVelopment Briefly
Views: 796
Rating: undefined out of 5
Keywords:
Id: hguXj166f98
Channel Id: undefined
Length: 4min 37sec (277 seconds)
Published: Tue May 21 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.