This page was translated from English by the community.Learn more and join the MDN Web Docs community.
Reflect.get()
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.get() 정적 메서드는 객체의 속성을 가져오는 함수입니다.target[propertyKey]와 비슷합니다.
In this article
시도해 보기
const object1 = { x: 1, y: 2,};console.log(Reflect.get(object1, "x"));// Expected output: 1const array1 = ["zero", "one"];console.log(Reflect.get(array1, 1));// Expected output: "one"구문
js
Reflect.get(target, propertyKey[, receiver])매개변수
target속성을 가져올 대상 객체.
propertyKey가져올 속성의 이름.
receiverOptional대상 속성이 접근자라면
this의 값으로 사용할 값.Proxy와 함께 사용하면, 대상을 상속하는 객체를 사용할 수 있습니다.
반환 값
속성의 값.
예외
설명
Reflect.get 메서드는 객체 속성의 값을 가져올 수 있습니다.속성 접근자의 함수판이라고 할 수 있습니다.
예제
>Reflect.get() 사용하기
js
// Objectvar obj = { x: 1, y: 2 };Reflect.get(obj, "x"); // 1// ArrayReflect.get(["zero", "one"], 1); // "one"// handler 매개변수와 Proxyvar x = { p: 1 };var obj = new Proxy(x, { get(t, k, r) { return k + "bar"; },});Reflect.get(obj, "foo"); // "foobar"명세
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-reflect.get> |