WeakMap.prototype.delete()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
delete()
메서드는 WeakMap
객체에서 특정 요소를 제거합니다.
시도해보기
const weakmap1 = new WeakMap();
const object1 = {};
weakmap1.set(object1, 42);
console.log(weakmap1.delete(object1));
// Expected output: true
console.log(weakmap1.has(object1));
// Expected output: false
구문
js
delete key;
매개변수
key
-
WeakMap
객체에서 제거할 요소의 키입니다.
반환 값
WeakMap
겍체의 요소가 성공적으로 제거된 경우 true
입니다. WeakMap
에서 키를 찾을 수 없거나 키가 객체가 아닌 경우는 false
입니다.
예제
delete() 메서드 사용하기
js
const wm = new WeakMap();
wm.set(window, "foo");
wm.delete(window); // true 반환. 성공적으로 제거됨.
wm.has(window); // false 반환. window 객체는 더이상 WeakMap에 있지않음.
명세
Specification |
---|
ECMAScript® 2025 Language Specification # sec-weakmap.prototype.delete |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
delete |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.