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 September 2016.
Reflect.get()
정적 메서드는 객체의 속성을 가져오는 함수입니다. target[propertyKey]
와 비슷합니다.
시도해보기
const object1 = {
x: 1,
y: 2,
};
console.log(Reflect.get(object1, "x"));
// Expected output: 1
const array1 = ["zero", "one"];
console.log(Reflect.get(array1, 1));
// Expected output: "one"
구문
js
Reflect.get(target, propertyKey[, receiver])
매개변수
target
-
속성을 가져올 대상 객체.
propertyKey
-
가져올 속성의 이름.
receiver
Optional-
대상 속성이 접근자라면
this
의 값으로 사용할 값.Proxy
와 함께 사용하면, 대상을 상속하는 객체를 사용할 수 있습니다.
반환 값
속성의 값.
예외
설명
Reflect.get
메서드는 객체 속성의 값을 가져올 수 있습니다. 속성 접근자의 함수판이라고 할 수 있습니다.
예제
Reflect.get()
사용하기
js
// Object
var obj = { x: 1, y: 2 };
Reflect.get(obj, "x"); // 1
// Array
Reflect.get(["zero", "one"], 1); // "one"
// handler 매개변수와 Proxy
var x = { p: 1 };
var obj = new Proxy(x, {
get(t, k, r) {
return k + "bar";
},
});
Reflect.get(obj, "foo"); // "foobar"
명세
Specification |
---|
ECMAScript® 2025 Language Specification # sec-reflect.get |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
get |
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.