Same way as you would in JavaScript.

delete myArray[key];

Note that this sets the element to undefined.

Better to use the Array.prototype.splice function:

const index = myArray.indexOf(key, 0);
if (index > -1) {
   myArray.splice(index, 1);
}
Answer from blorkfish on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › how-do-i-remove-an-array-item-in-typescript
How do I Remove an Array Item in TypeScript? - GeeksforGeeks
July 23, 2025 - Initial Array: JavaScript, 1, GeeksforGeeks, 2, TypeScript Removed Item: JavaScript Array After removing item: 1, GeeksforGeeks, 2, TypeScript · The pop() method will delete the last element of the array without passing any parameter.
🌐
Reddit
reddit.com › r/learnprogramming › why is removing a specific element from an array so needlessly complicated in javascript?
r/learnprogramming on Reddit: Why is removing a specific element from an array so needlessly complicated in Javascript?
January 17, 2023 -

I'm just looking for something along the lines of:

array.remove("element")

Upon Googling for solutions so far I've found

Remove an element at any index with splice

Remove an element from an array with a for loop and push

Remove an element at any position of an array with slice and concat

There's more but I'm assuming you get the point. Why is this seemingly simple task so ridiculously complicated with Javascript?

Did nobody think to include a ".remove()" method when they were first developing Javascript? Is there a quirk of the language that makes it impossible? What is the reason for this?

🌐
Angular Wiki
angularjswiki.com › angular › how-to-remove-an-element-from-array-in-angular-or-typescript
How To Remove an element from Array in Angular/Typescript | Angular Wiki
To remove an element from an array in Angular or Typescript we can use javascript’s delete operator or Array splice function.
🌐
HowToDoInJava
howtodoinjava.com › home › typescript › typescript – how to remove items from array
TypeScript - How to Remove Items from Array
July 26, 2023 - Learn to remove or pop items from an array in TypeScript using pop(), shift(), splice(), filter() and delete operator with examples.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › splice
Array.prototype.splice() - JavaScript | MDN
An integer indicating the number of elements in the array to remove from start. If deleteCount is omitted, or if its value is greater than or equal to the number of elements after the position specified by start, then all the elements from start to the end of the array will be deleted. However, if you wish to pass any itemN parameter, you should pass Infinity as deleteCount to delete all elements after start, because an explicit undefined gets converted to 0.
🌐
Bobby Hadz
bobbyhadz.com › blog › typescript-remove-element-from-array
Remove Element(s) from an Array in TypeScript | bobbyhadz
The filter method is useful when you only need the elements from an array that satisfy a specific condition, e.g. get only the odd numbers from an array that contains both odd and even numbers. The delete operator is used to remove a property from an object, however, you might see developers using it with arrays.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › typescript tutorial › typescript remove item from array
TypeScript remove item from array | Learn the Examples and Parameters
April 6, 2023 - In typescript, to remove or delete any item in the array, we can use the delete operator as JavaScript, but it will remove the property of the object of the array where it cannot shift any index or key values.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Java2Blog
java2blog.com › home › typescript › how to clear array in typescript
How to Clear Array in TypeScript - Java2Blog
November 8, 2023 - ... Reassign the variable storing ... to constant variable. This is better approach performance wise. ... Iterate over array using for or while loop. Use Array.pop() method to remove element from the array....
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › typescript › remove an array item in typescript
How to Remove an Array Item in TypeScript | Delft Stack
February 2, 2024 - let array = ["white", "yellow", "black", "green", "blue"]; delete array[1]; console.log("The array after deletion : " + array); ... Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides.
🌐
SPGuides
spguides.com › typescript-remove-item-from-array
How to Remove Items from Arrays in TypeScript
June 30, 2025 - Learn 7 proven methods to remove items from arrays in TypeScript. Master splice(), filter(), slice(), and more with practical examples for everyday coding.
🌐
TutorialsPoint
tutorialspoint.com › home › typescript › typescript array splice method
TypeScript Array Splice Method
December 18, 2016 - TypeScript - null vs. undefined ... howMany − An integer indicating the number of old array elements to remove. If howMany is 0, no elements are removed. element1, ..., elementN − The elements to add to the array. If you don't specify any elements, splice simply removes the elements from the array.
🌐
Tiloid
tiloid.com › p › removing-an-array-item
Removing an Array Item - Tiloid
January 10, 2023 - In TypeScript, you can remove an item from an array using different methods, depending on your specific requirements and the version of TypeScript you...
🌐
Reddit
reddit.com › r/functionalprogramming › how do i remove every element from an array in a "pure" way?
r/functionalprogramming on Reddit: How do I remove every element from an array in a "pure" way?
September 1, 2023 -

Hello, I am learning functional programming for the first time and I was working with array methods, I believe that there are many "pure" array methods for our usual operations (push, pop), etc.

For pushing elements or well at least adding elements, I would use concat.

const addElementsToArray = (s:State) => {
    // logic
    const newArray = //logic
    return{
     ...s,
     array: s.array.concat(newArray)

    }
}

And for popping/removing certain elements, I would use filter. But how do I actually remove everything from an array? And return an empty array?

Shall I just put a crazy condition inside my filter method so much so that it would return an empty array because nothing actually meets the filter requirements?

I have actually tried:

const addElementsToArray = (s:State) => {
    // logic
    return{
     ...s,
     array: []
    }
}

But just doing array: [] seems a little weird and impure. Or is this actually pure since I'm making a copy of the entire State object where array resides?

🌐
Webdevtutor
webdevtutor.net › blog › typescript-remove-all-item-from-array
Removing All Items from an Array in TypeScript: A Complete Guide
One of the simplest ways to clear an array in TypeScript is by setting its length to 0. This method truncates the array to an empty array effectively removing all its elements. let myArray: number[] = [1, 2, 3, 4, 5]; myArray.length = 0; Another approach is to use the splice method to remove ...
Top answer
1 of 16
5711

Ways to clear an existing array A:

Method 1

(this was my original answer to the question)

A = [];

This code will set the variable A to a new empty array. This is perfect if you don't have references to the original array A anywhere else because this actually creates a brand new (empty) array. You should be careful with this method because if you have referenced this array from another variable or property, the original array will remain unchanged. Only use this if you only reference the array by its original variable A.

This is also the fastest solution.

This code sample shows the issue you can encounter when using this method:

var arr1 = ['a','b','c','d','e','f'];
var arr2 = arr1;  // Reference arr1 by another variable 
arr1 = [];
console.log(arr2); // Output ['a','b','c','d','e','f']

Method 2 (as suggested by Matthew Crumley)

A.length = 0

This will clear the existing array by setting its length to 0. It also works when using "strict mode" in ECMAScript 5 because the length property of an array is a read/write property.

Method 3 (as suggested by Anthony)

A.splice(0,A.length)

Using .splice() will work perfectly, but since the .splice() function will return an array with all the removed items, it will actually return a copy of the original array. Benchmarks suggest that this has no effect on performance whatsoever.

Method 4 (as suggested by tanguy_k)

while(A.length > 0) {
    A.pop();
}

This solution is not very succinct, and it is also the slowest solution, contrary to earlier benchmarks referenced in the original answer.

Performance

Of all the methods of clearing an existing array, methods 2 and 3 are very similar in performance and are a lot faster than method 4. See this benchmark.

As pointed out by Diadistis in their answer below, the original benchmarks that were used to determine the performance of the four methods described above were flawed. The original benchmark reused the cleared array so the second iteration was clearing an array that was already empty.

The following benchmark fixes this flaw: http://jsben.ch/#/hyj65. It clearly shows that methods #2 (length property) and #3 (splice) are the fastest (not counting method #1 which doesn't change the original array).


This has been a hot topic and the cause of a lot of controversy. There are actually many correct answers and because this answer has been marked as the accepted answer for a very long time, I will include all of the methods here.

2 of 16
2755

If you need to keep the original array because you have other references to it that should be updated too, you can clear it without creating a new array by setting its length to zero:

A.length = 0;
🌐
CoreUI
coreui.io › blog › how-to-remove-element-from-javascript-array
How to Remove Elements from a JavaScript Array · CoreUI
February 13, 2025 - The filter method allows you to preserve existing elements that meet your condition. Because it creates a new array, your original array is left intact. Some developers use the delete operator to delete element directly from an array. However, this approach leaves an empty slot in the array, rather than collapsing its indices. You may end up with an empty array index that can cause confusion when checking array length or iterating with a while loop. const items = ['keyboard', 'mouse', 'monitor'] delete items[1] console.log(items) // ['keyboard', empty, 'monitor']
🌐
Convex
convex.dev › core concepts › arrays & collections › remove item from array
Remove Item from Array | TypeScript Guide by Convex
The filter method never throws an error; it simply returns all elements if none match the exclusion criteria. When removing items from arrays of objects, identify elements by their properties:
🌐
DEV Community
dev.to › jsdevspace › 9-ways-to-remove-elements-from-arrays-in-javascript-4be6
9 Ways to Remove Elements from Arrays in JavaScript - DEV Community
August 6, 2024 - Here are five common ways to remove elements from arrays in JavaScript: The splice(start, deleteCount, item1ToAdd, item2ToAdd, ...) method changes the contents of an array by removing or replacing existing elements and/or adding new elements ...