Movatterモバイル変換


[0]ホーム

URL:


  1. 개발자를 위한 웹 기술
  2. JavaScript
  3. JavaScript 참고서
  4. 표준 내장 객체
  5. Reflect
  6. Reflect.has()

This page was translated from English by the community.Learn more and join the MDN Web Docs community.

View in EnglishAlways switch to English

Reflect.has()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2016년 9월⁩.

Reflect.has() 정적 메서드는in 연산자의 함수판입니다.

시도해 보기

const object1 = {  property1: 42,};console.log(Reflect.has(object1, "property1"));// Expected output: trueconsole.log(Reflect.has(object1, "property2"));// Expected output: falseconsole.log(Reflect.has(object1, "toString"));// Expected output: true

구문

js
Reflect.has(target, propertyKey);

매개변수

target

속성을 탐색할 객체.

propertyKey

탐색할 속성의 이름.

반환 값

객체가 속성을 가지고 있는지 나타내는Boolean.

예외

targetObject가 아니면TypeError.

설명

Reflect.has() 메서드는 객체에 속성이 존재하는지 판별할 수 있습니다.in 연산자처럼 동작합니다.

예제

Reflect.has() 사용하기

js
Reflect.has({ x: 0 }, "x"); // trueReflect.has({ x: 0 }, "y"); // false// 프로토타입 체인에 존재하는 속성도 true 반환Reflect.has({ x: 0 }, "toString");// .has() 처리기 메서드를 가진 Proxyobj = new Proxy(  {},  {    has(t, k) {      return k.startsWith("door");    },  },);Reflect.has(obj, "doorbell"); // trueReflect.has(obj, "dormitory"); // false

명세

Specification
ECMAScript® 2026 Language Specification
# sec-reflect.has

브라우저 호환성

같이 보기

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp