A RetroSearch Logo

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

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf below:

Object.getPrototypeOf() - JavaScript | MDN

Object.getPrototypeOf()

Baseline Widely available

Object.getPrototypeOf() メソッドは、指定されたオブジェクトのプロトタイプ (つまり、内部プロパティ [[Prototype]] の値) を返します。

試してみましょう
const prototype1 = {};
const object1 = Object.create(prototype1);

console.log(Object.getPrototypeOf(object1) === prototype1);
// Expected output: true
構文
Object.getPrototypeOf(obj)
引数
obj

プロトタイプを取得したいオブジェクト。

返値

指定されたオブジェクトのプロトタイプです。何も継承していないオブジェクトの場合は null です。

例 getPrototypeOf の使用
const proto = {};
const obj = Object.create(proto);
Object.getPrototypeOf(obj) === proto; // true
オブジェクト以外の型変換

ES5 では引数 obj がオブジェクトではない場合 TypeError が発生します。しかし ES2015 では対応する Object に変換されてから処理されます。

Object.getPrototypeOf("foo");
// TypeError: "foo" is not an object (ES5 code)
Object.getPrototypeOf("foo");
// String.prototype                  (ES2015 code)
仕様書 ブラウザーの互換性 関連情報

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