Study Guide: JavaScript->Inheritance

instanceof operator

The instanceof operator determines whether an object was instantiated as a child of another object, returning true if this was the case. instanceof is a binary infix operator whose left operand is an object and whose right operand is an object type. It returns true, if the left operand is of the type specified by the right operand. It differs from the .constructor property in that it "walks up the prototype chain". If object a is of type b, and b is an extension of c, then a instanceof b and a instanceof c both return true, whereas a.constructor === b returns true, while a.constructor === c returns false.

Inheritance by prototypes

The prototype of an object can be used to create fields and methods for an object. This prototype can be used for inheritance by assigning a new instance of the superclass to the prototype.[1]

function CoinObject {
 this.value = 0; 
 this.diameter = 1;

function Penny {
 this.value = 1;
Penny.prototype = new CoinObject;

function Nickel {
 this.value = 5;
Nickel.prototype = new CoinObject;

Inheritance by functions


To do:
Provide a recommended method for function-based inheritance - one reference is

function CoinObject {
 this.value = 0; 
 this.diameter = 1;


  1. ? Matthew Batchelder. "Object Oriented JavaScript" describes one way to implement inheritance in JavaScript.

  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.



Connect with defaultLogic
What We've Done
Led Digital Marketing Efforts of Top 500 e-Retailers.
Worked with Top Brands at Leading Agencies.
Successfully Managed Over $50 million in Digital Ad Spend.
Developed Strategies and Processes that Enabled Brands to Grow During an Economic Downturn.
Taught Advanced Internet Marketing Strategies at the graduate level.

Manage research, learning and skills at Create an account using LinkedIn to manage and organize your omni-channel knowledge. is like a shopping cart for information -- helping you to save, discuss and share.

  Contact Us