Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Object.getPrototypeOf()

El mètode Object.getPrototypeOf() retorna el prototipus (és a dir, el valor de la propietat interna [[Prototype]]) de l'objecte especificat.

Sintaxi

Object.getPrototypeOf(obj)

Paràmetres

obj
L'objecte del qual es retornarà el prototipus.

Exemples

var proto = {};
var obj = Object.create(proto);
Object.getPrototypeOf(obj) === proto; // true

Notes

A l'EcmaScript 5 llençarà una excepció TypeError si el paràmetre obj no és un objecte. A l'EcmaScript 6 el paràmetre serà forçat al tipus Object.

Object.getPrototypeOf("foo");
// TypeError: "foo" no és un objecte (codi EcmaScript 5)
Object.getPrototypeOf("foo");
// String.prototype                  (codi EcmaScript 6)

Especificacions

Especificació Estat Comentaris
ECMAScript 5.1 (ECMA-262)
The definition of 'Object.getPrototypeOf' in that specification.
Standard Definició inicial.
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Object.getProtoypeOf' in that specification.
Standard  

Compatibilitat amb navegadors

Característica Chrome Firefox (Gecko) Internet Explorer Opera Safari
Suport bàsic 5 3.5 (1.9.1) 9 12.10 5
Característica Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Suport bàsic ? ? ? ? ? ?

Notes específiques per a Opera

Tot i que versions antigues de Opera no suporten Object.getPrototypeOf(), Opera soporta la propietat no standard __proto__ a partir de la versió 10.50.

Vegeu també

Document Tags and Contributors

 Contributors to this page: enTropy
 Last updated by: enTropy,