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/get below:

Reflect.get() - JavaScript | MDN

Reflect.get()

Baseline Widely available

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"
구문
Reflect.get(target, propertyKey[, receiver])
매개변수
target

속성을 가져올 대상 객체.

propertyKey

가져올 속성의 이름.

receiver Optional

대상 속성이 접근자라면 this의 값으로 사용할 값. Proxy와 함께 사용하면, 대상을 상속하는 객체를 사용할 수 있습니다.

반환 값

속성의 값.

예외

target이 Object가 아니면 TypeError.

설명

Reflect.get 메서드는 객체 속성의 값을 가져올 수 있습니다. 속성 접근자의 함수판이라고 할 수 있습니다.

예제 Reflect.get() 사용하기
// 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"
명세 브라우저 호환성 같이 보기

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