Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

Map.prototype.delete()

BaselineWidely available

Thedelete() method ofMap instances removes the specified element from this map bykey.

Try it

const map1 = new Map();map1.set("bar", "foo");console.log(map1.delete("bar"));// Expected result: true// True indicates successful removalconsole.log(map1.has("bar"));// Expected result: false

Syntax

js
mapInstance.delete(key)

Parameters

key

The key of the element to remove from theMap object.

Return value

true if an element in theMap object existed and has been removed, orfalse if the element does not exist.

Examples

Using delete()

js
const myMap = new Map();myMap.set("bar", "foo");console.log(myMap.delete("bar")); // Returns true. Successfully removed.console.log(myMap.has("bar")); // Returns false. The "bar" element is no longer present.

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-map.prototype.delete

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp