Array filter creates a new array with all elements this pass the test implemented by the provided function. In this lesson we discuss if only a truthy or Falsey value are required as the return value to the function, which in turn s allows us to being creative in how we perform the filter. We end the lesson by looking at a example showing how chaining multiple array methods together can leads to very nice, Dec Larative code.
Const LESSONS =[{title:' Javascript Arrays in Depth-join ', Views:960, Tags: [' Array ', ' join ']}, {title:' Javascript Arrays in Depth-concat ', Views:1050, Tags: [' Array ', ' concat ']}, {title:' Javascript Arrays in Depth-slice ', Views:2503, Tags: [' Array ', ' slice ']}, {title:' Javascript Functions in Depth-bind ', Views:2500, Tags: [' Functions ', ' bind ']}];const minviews= 1000; Const Searchterm= ' array '; Const filtered=Lessons. Filter (x= X.tags.indexof (Searchterm) >-1). Filter (x= x.views >minviews). Sort ((A, B)= B.views-a.views). Map (x= ' <li>${x.title}</li> '). Join (' \ n ')); Console.log ('<ul>${filtered}</ul> ');
[Javascript] Array Methods in Depth-filter