A RetroSearch Logo

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

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/Object/getPrototypeOf below:

getPrototypeOf ยท WebPlatform Docs

getPrototypeOf Summary

Returns the prototype of an object.

Syntax
Object.getPrototypeOf( object )
object
Required. The object that references the prototype.
Return Value

The prototype of the object argument. The prototype is also an object.

Examples

The following example illustrates the use of the Object.getPrototypeOf function.


 function Pasta(grain, width) {
     this.grain = grain;
     this.width = width;
 }
 
 var spaghetti = new Pasta("wheat", 0.2);

 
 var proto = Object.getPrototypeOf(spaghetti);

 
 
 proto.foodgroup = "carbohydrates";
 document.write(spaghetti.foodgroup + " ");

 
 
 var result = (proto === Pasta.prototype);
 document.write(result + " ");

 
 
 var result = proto.isPrototypeOf(spaghetti);
 document.write(result);

 

The following example uses the Object.getPrototypeOf function to validate data types.

var reg = /a/;
 var result = (Object.getPrototypeOf(reg) === RegExp.prototype);
 document.write(result + " ");

 var err = new Error("an error");
 var result = (Object.getPrototypeOf(err) === Error.prototype);
 document.write(result);

 
Exceptions

If the object argument is not an object, a TypeError exception is thrown.

See also Other articles Attributions

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