From the course: Learning Functional Programming with JavaScript ES6+

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Slicing

Slicing - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript ES6+

Start my 1-month free trial

Slicing

- [Narrator] The next built in array method we're going to be looking at is called slice. Unlike the last few built in methods we've seen, slice is not a higher order function. It doesn't take a function as an argument, like map or filter, but it does have some important uses when working with arrays in JavaScript. I mentioned earlier in the course that their are some array functions that mutant the arrays you call them on. Sort, which we'll look at in a later video, is one of those functions. And we also have push and pop which add and remove elements from the array respectively, but also mutate the array. So as I mentioned, these functions don't just return a copy of the original array, they actually mutate the original array. And this isn't always obvious. It's for this reason that I strongly recommend that you use ESLint, which I showed you how to set up in a previous video, to catch unintended mutations for you. So what does this mean for us? JavaScipt provides these very useful…

Contents