Map.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.
Map
인스턴스의 has()
메서드는 주어진 키에 해당하는 요소의 존재 여부를 가리키는 불리언 값을 반환합니다.
시도해보기
const map1 = new Map();
map1.set("bar", "foo");
console.log(map1.has("bar"));
// Expected output: true
console.log(map1.has("baz"));
// Expected output: false
구문
js
has(key)
매개변수
key
-
Map
객체에서 존재를 확인할 요소의 키
반환 값
만약 주어진 키에 해당하는 요소가 Map
객체에 존재한다면 true
, 그렇지 않으면 false
예제
has() 사용하기
js
const myMap = new Map();
myMap.set("bar", "foo");
console.log(myMap.has("bar")); // true
console.log(myMap.has("baz")); // false
명세서
Specification |
---|
ECMAScript® 2025 Language Specification # sec-map.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
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.