---
title: "Remove Item in an Array in JavaScript"  
description: "Remove Item in an Array in JavaScript"  
author: "Anonymous User"  
published: 2021-07-20  
updated: 2021-07-20  
canonical: https://www.mindstick.com/forum/156564/remove-item-in-an-array-in-javascript  
category: "javascript"  
tags: ["javascript", "array"]  
reading_time: 2 minutes  

---

# Remove Item in an Array in JavaScript

How can I [remove](https://yourviews.mindstick.com/story/4554/8-harmful-weeds-to-remove-from-garden) a specific [item from an array](https://www.mindstick.com/forum/159191/remove-a-specific-item-from-an-array-in-javascript) in [javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript)?

## Replies

### Reply by Anonymous User

In JavaScript you can use an [array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) which is used to store a set of values ​​in a variable. You can add or remove values ​​in an array at any index position.

Below we will discuss a variety of methods that are used to add or remove an element from an array. Let's go through it :

- pop() function: pop() method remove elements from the end of an array.
- shift() function: shift() method is used to remove elements from the beginning of an array.
- splice() function: splice() method is used to remove elements from a specific index of an array.
- filter() function: filter() method is used to remove elements programmatically.

Let's check all the method one by one in the below example :

```
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
<script>
    function func() {
        var arr = ['shift', 'splice', 'filter', 'pop'];
        var popped = arr.pop();
        document.write('Removed element: ' + popped + '<br>');
        document.write('Remaining elements: ' + arr + '<br>' + '<br>');
    }
    func();
    var array = ['pop', 'splice', 'filter', 'shift']
    document.write('Original array: ' + array + '<br>')
    while (array.length) {
        array.pop();
    }
    document.write('Array Length: ' + array.length + '<br>' + '<br>');
    function shifted() {
        var arr = ['shift', 'splice', 'filter', 'pop'];
        var shifted = arr.shift();
        document.write('Removed element: ' + shifted + '<br>');
        document.write('Remaining elements: ' + arr + '<br>' + '<br>');
    }
    shifted();
    function spliced() {
        var arr = ['shift', 'splice', 'filter', 'pop'];
        // Removing the specified element from the array
        var spliced = arr.splice(1, 1);
        document.write('Removed element: ' + spliced + '<br>');
        document.write('Remaining elements: ' + arr + '<br>' + '<br>');
    }
    spliced();
</script>
</html>
```

Hope this code will be helpful for you.

Happy Coding!


---

Original Source: https://www.mindstick.com/forum/156564/remove-item-in-an-array-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
