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);
}
More Related Contents:
- TypeScript array to string literal type
- TypeScript Objects as Dictionary types as in C#
- Filtering an array in angular2
- A cmdlet which returns multiple objects, what collection type is it, if any? [PowerShell]
- Defining an array of differing generic types in TypeScript
- Defining array with multiple types in TypeScript
- Class-validator – validate array of objects
- Typescript says array.pop() might return undefined even when array is guaranteed to contain elements
- Creating a specific pattern with two-dimensional array in scala
- maximize the top element of the stack after performing exactly K operations
- How to split a string into an array in Bash?
- Finding three elements in an array whose sum is closest to a given number
- How to convert an array of objects to object with key value pairs
- Get random elements from array in Swift
- Why are the elements of an array formatted as zeros when they are multiplied by 1/2 or 1/3?
- Can min/max of moving window achieve in O(N)?
- Sorting a Swift array by ordering from another array
- Exporting an array in bash script
- the best way to make codeigniter website multi-language. calling from lang arrays depends on lang session?
- A confusion about ${array[*]} versus ${array[@]} in the context of a bash completion
- Why does gulp.src not like being passed an array of complete paths to files?
- Convert bytes/UInt8 array to Int in Swift
- Is there YAML syntax for sharing part of a list or map?
- Multidimensional arrays in Swift
- Matching up two vectors in R
- What does $0 and $1 mean in Swift Closures?
- How to get random values from array in C# [duplicate]
- Create Chart from Array data and not range
- VBA – Returning array from Property Get
- ReDim Preserve “Subscript Out of Range”