Andthisbuildermethodjusttakes a singlefunction, whichisgoingtohaveoneparameterofitem, whichisjusteachiteminsideofthearray, andthenwedon't needtoreturn a trueorfalsestatementonwhetherornotwewanttoincludethatinthenewarray.
Andifyousaythatyousee, wegetin a rageoverherefouritems, allofthemwith a pricelessthanorequalto $100.
Andthat's perfect.
Thisfilteredofraymethodissupereasytouse.
Allyoudoisreturn, trueorfalseforeachitem.
Andifit's true, it's inthenewarray.
Andifit's false, it's notinthenewarray.
Andthegreatthingaboutthisfiltermethodandalltheothermethodsfor a raisethatwe'regoingtobecoveringisthattheyactuallydon't changetheunderlyingobjectthatyou'refilteringoversowecanlogtheitemsarray.
Sowenolongerneedthisreturnstatementhere, andwedon't actuallyneedtologanythingdownheresowecouldjustsayforeachandthisisgoingtoworkverysimilarlytoe a fourloop.
Butit's goingtotake a functionhereinstead, andwehaveourfirstparameterand I function, whichisitemjustlikebefore.
Thenextmethodthat I wanttotalkaboutthereducedmethodis a bitdifferentthanalloftheothermethods, sinceit's actuallydoingsomeoperationonthearrayandreturning a combinationofallthosedifferentoperations.
Soifwewantedtogetthetotalpriceofallthedifferentitemsinthisray, normallywhatyoudoisyouwouldjustdo a fourloopandaddthepriceeverysingletime, andattheendofthefourloopyou'd printouttheprice.
Butyoucanusethereducemethodtodothisinstead, andthesyntaxforthereducemethodis a bitdifferent.
Insteadoftakinganitem, ittakesanitemand a propertyforwhatwewanttoreduceeverythinginto.
Soit's a bitmoreconfusing, butthisisincrediblyusefulwhenyouneedtodosomekindofoperationcumulativelytoealltheitemsinanarraysuchasgrabbingthetotalpriceforalltheitems.
Nowthelastelementthat I wanttotalkaboutforthemethodsistheincludesmethod, andthisis a bitdifferentbecauseitdoesn't actuallytake a function, isjustgoingtotake a singleargument.
Soinsteadofpassing a bunchofobjectsinourray, thereisgoingtodoanarrayofnumbers 12345 andthenwe'regoingtochangethevalueofthistwoincludestwo.
Thisisreallyconvenientwhenyoujustneedtocheckifanarrayhas a valueofwithoutdoing a complexfind, especiallywhenyouhavesuch a simplearrayofjustnumbers, forexample, andthat's alleightoftheincrediblyusefulJavaScriptarraymethodsthat I wanttocover.
Soifyouguysdidenjoythisvideo, makesurecheckoutmyotherjobscriptrelatedvideosoverhereandsubscribetomychannelformorevideosjustlikethis, Thankyouguysverymuchforwatchingandhave a goodday.