JavaScript Inheritance and Prototype # OOPS JS
Introduction to Inheritance and Prototype Chain in JavaScript Introduction This article explains inheritance and the Prototype Chain in JavaScript. JavaScript is a bit confusing for developers experienced in class-based languages (like Java or C++), since it is dynamic and does not provide a class implementation (although the keyword class is a reserved keyword and cannot be used as a variable name). When it comes to inheritance, JavaScript only has one construct: objects. Each object has an internal link to another object called its prototype. That prototype object has a prototype of its own, and so on until an object is reached with null as its prototype. null, by definition, has no prototype, and acts as the final link in this prototype chain. In JavaScript, a prototype is a property of a function and the object created by constructor functions. The prototype of a function is an object. It's main use is when a function is used as a constructor. Prototype and prop