filmov
tv
JavaScript How To Remove An Item From Array Tutorial

Показать описание
In this tutorial we’ll look at some different ways to use JavaScript to remove an item from an array.
Don’t forget to subscribe to the Junior Developer Central channel for more videos and tutorials!
Imagine you have an array of values; numbers or strings for example. You might have the need to remove one or more elements. For example you might want to know:
How to remove specific item from array in JavaScript
How to remove last item from array in JavaScript
How to remove duplicate item from array in JavaScript
In this tutorial we’ll explore the above scenarios and find solutions for solving different ways of removing items from an array.
We’ll start off simple by looking at how to remove items from an array using JavaScript’s pop function. This is a function that’s available on all arrays and it will remove the last item from an array and you can optionally store it too.
Another option is to use the shift function in JavaScript. This will actually take the item from the front of the array and in a similiar way to pop, you can store the value removed.
With those two basic options covered, let’s look at some of JavaScript’s filter higher order function to remove any items that don’t meet a certain condition. This can be a great way of removing lots of items from an array when you want rid of values based on a certain condition.
Finally, we can use the filter function mentioned above when we want to remove duplicate items from arrays in JavaScript. We’ll cover this as a final example as this is quite a common thing required for a Junior Developer to do.
Don’t forget to subscribe to the Junior Developer Central channel for more videos and tutorials!
Imagine you have an array of values; numbers or strings for example. You might have the need to remove one or more elements. For example you might want to know:
How to remove specific item from array in JavaScript
How to remove last item from array in JavaScript
How to remove duplicate item from array in JavaScript
In this tutorial we’ll explore the above scenarios and find solutions for solving different ways of removing items from an array.
We’ll start off simple by looking at how to remove items from an array using JavaScript’s pop function. This is a function that’s available on all arrays and it will remove the last item from an array and you can optionally store it too.
Another option is to use the shift function in JavaScript. This will actually take the item from the front of the array and in a similiar way to pop, you can store the value removed.
With those two basic options covered, let’s look at some of JavaScript’s filter higher order function to remove any items that don’t meet a certain condition. This can be a great way of removing lots of items from an array when you want rid of values based on a certain condition.
Finally, we can use the filter function mentioned above when we want to remove duplicate items from arrays in JavaScript. We’ll cover this as a final example as this is quite a common thing required for a Junior Developer to do.
Комментарии