A RetroSearch Logo

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

Search Query:

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

Reflect.getPrototypeOf() - JavaScript | MDN

Reflect.getPrototypeOf()

Baseline Widely available

Reflect.getPrototypeOf() 정적 메서드는 주어진 객체의 프로토타입을 반환합니다. Object.getPrototypeOf()와 거의 동일합니다.

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

const proto1 = Reflect.getPrototypeOf(object1);

console.log(proto1);
// Expected output: Object {  }

console.log(Reflect.getPrototypeOf(proto1));
// Expected output: null
구문
Reflect.getPrototypeOf(target);
매개변수
target

프로토타입을 가져올 대상 객체.

반환 값

주어진 객체의 프로토타입. 상속한 속성이 없으면 null을 반환합니다.

예외

target이 Object가 아니면 TypeError.

설명

Reflect.getPrototypeOf() 메서드는 주어진 객체의 프로토타입([[Prototype]] 내부 객체의 값 등)을 반환합니다.

예제 Reflect.getPrototypeOf() 사용하기
Reflect.getPrototypeOf({}); // Object.prototype
Reflect.getPrototypeOf(Object.prototype); // null
Reflect.getPrototypeOf(Object.create(null)); // null
Object.getPrototypeOf()와 비교
// 객체에는 동일한 결과
Object.getPrototypeOf({}); // Object.prototype
Reflect.getPrototypeOf({}); // Object.prototype

// ES5에서는 비객체 대상에서 모두 오류
Object.getPrototypeOf("foo"); // Throws TypeError
Reflect.getPrototypeOf("foo"); // Throws TypeError

// ES2015에서는 Reflect만 오류, Object는 객체로 변환
Object.getPrototypeOf("foo"); // String.prototype
Reflect.getPrototypeOf("foo"); // Throws TypeError

// ES2015 Object 동작을 따라하려면 객체 변환과정 필요
Reflect.getPrototypeOf(Object("foo")); // String.prototype
명세 브라우저 호환성 같이 보기

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