.delete(location)

Description

Delete is a method that takes an array, string or object as input. It returns the input with an index or a key deleted

Parameters

Insert takes the location to insert a value and the value to insert as parameters.

Usage On Arrays

arr = [1,2,3,3,4,5]
// setup the array

log arr.delete(3)
// returns "arr" with the 3rd index removed: [1,2,3,4,5]

Usage On Strings

str = "helllo world"
// setup the string

log str.delete(4)
// returns the string but with the 4th character deleted: "hello world"

Usage On Objects

obj = {"key":"value"}
// setup the object

log obj.delete("key")
// returns {}

Last updated