Removes the entry associated with a given key from a
.delete() method accepts a
key parameter and returns
true if the deletion was successful. Otherwise, if the
key does not exist,
false is returned.
Data can be removed from a
Map object using the
const fruits = new Map([['Apples', 5],['Oranges', 8],]);console.log(fruits.delete('Oranges')); // Output: trueconsole.log(fruits.delete('Strawberries')); // Output: false
.delete() statement returns
fruits contain an entry with
Oranges as a key and has successfully removed it. The second statement returns
false because an entry with the
Strawberries key does not exist in
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
Front-End EngineerFront-end engineers work closely with designers to make websites beautiful, functional, and fast.
Includes 34 Courses
With Professional Certification