Map.prototype.delete()
delete()
메서드는 키로 Map
객체에서 특정 요소를 제거합니다.
시도해보기
구문
delete(key)
매개 변수
key
-
Map
객체에서 제거할 요소의 키
반환 값
Map
객체에서 요소가 존재하고 제거된 경우 true
, 그렇지 않고 해당 요소가 존재하지 않으면 false
를 반환합니다.
예제
delete() 사용하기
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.
명세서
Specification |
---|
ECMAScript Language Specification # sec-map.prototype.delete |
브라우저 호환성
BCD tables only load in the browser