WeakMap.prototype.has()
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.
has()
메서드는 지정된 키를 가진 요소가 WeakMap
객체에 존재하는지를 나타내는 불리언 값을 반환합니다.
시도해보기
const weakmap1 = new WeakMap();
const object1 = {};
const object2 = {};
weakmap1.set(object1, "foo");
console.log(weakmap1.has(object1));
// Expected output: true
console.log(weakmap1.has(object2));
// Expected output: false
구문
js
has(key);
매개변수
key
-
필수로 요구되며,
WeakMap
객체에서 존재 여부를 테스트할 요소의 키입니다.
반환 값
- 불리언
-
WeakMap
객체에 지정된 키를 가진 요소가 있으면true
를 반환하고, 그렇지 않으면false
를 반환합니다.
예제
has 메서드 사용하기
js
const wm = new WeakMap();
wm.set(window, "foo");
wm.has(window); // true 반환
wm.has("baz"); // false 반환
명세서
Specification |
---|
ECMAScript® 2025 Language Specification # sec-weakmap.prototype.has |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
has |
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.