A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has below:

Reflect.has() - JavaScript | MDN

Reflect.has()

Baseline Widely available

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

시도해 보기
const object1 = {
  property1: 42,
};

console.log(Reflect.has(object1, "property1"));
// Expected output: true

console.log(Reflect.has(object1, "property2"));
// Expected output: false

console.log(Reflect.has(object1, "toString"));
// Expected output: true
구문
Reflect.has(target, propertyKey);
매개변수
target

속성을 탐색할 객체.

propertyKey

탐색할 속성의 이름.

반환 값

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

예외

target이 Object가 아니면 TypeError.

설명

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

예제 Reflect.has() 사용하기
Reflect.has({ x: 0 }, "x"); // true
Reflect.has({ x: 0 }, "y"); // false

// 프로토타입 체인에 존재하는 속성도 true 반환
Reflect.has({ x: 0 }, "toString");

// .has() 처리기 메서드를 가진 Proxy
obj = new Proxy(
  {},
  {
    has(t, k) {
      return k.startsWith("door");
    },
  },
);
Reflect.has(obj, "doorbell"); // true
Reflect.has(obj, "dormitory"); // false
명세 브라우저 호환성 같이 보기

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4