// This is the code that prompted / created the blog post // https://www.andyjarrett.com/posts/2024/exploring-array-methods-including-push-pop-shift-unshift-map-filter-reduce-and-others/ // push() ["🥶","🥶","🥶","🥶"].push('🥵') // = ["🥶","🥶","🥶","🥶","🥵"] // pop() ["😎","🥵","🥶","🤢"].pop() // = ["😎","🥵","🥶"] // shift() ["😎","🥵","🥶","🤢"].shift() // = ["🥵","🥶","🤢"] // unshift() ["😎","🥵","🥶","🤢"].unshift('💩') // = ["💩","😎","🥵","🥶","🤢"] // map() ["😎","🥵","🥶","🤢"].map(item => item + '!') // = ["😎!","🥵!","🥶!","🤢!"] // filter() ["😎","🥵","🥶","🤢"].filter(item => item === '🥶') // = ["🥶"] // reduce() [1,2,3].reduce((acc, val) => acc + val, 0) // = 6 // some() [1,2,3].some(val => val > 2) // = true // every() [1,2,3].every(val => val > 0) // = true // find() [1,2,3].find(val => val > 2) // = 3 // findIndex() [1,2,3].findIndex(val => val > 2) // = 2 // reverse() ["😎","🥵","🥶","🤢"].reverse() // = ["🤢","🥶","🥵","😎"] // at() ["😎","🥵","🥶","🤢"].at(1) // = 🥵 // slice() ["😎","🥵","🥶","🤢"].slice(1, 2) // = ["🥵"] // concat() ["🥶"].concat(["🥵"]) // = ["🥶","🥵"] // includes() ["😎","🥵","🥶","🤢"].includes('🥵') // = true // indexOf() ["😎","🥵","🥶","🤢"].indexOf('🥵') // = 1 // join() ["😎","🥵","🥶","🤢"].join(' ') // = "😎 🥵 🥶 🤢" // flat() [1,[2,3],[4,5]].flat() // = [1,2,3,4,5] // flatMap() [1,2,3].flatMap(val => [val, val * 2]) // = [1,2,2,4,3,6]