Prototype-based Inheritance and Prototype chain in JavaScript (ES5)

In this article, we are going to deep dive into JavaScript prototype and understand how Object-Constructor relationship works

Uday Hiwarale
JsPoint

--

JavaScript is weird. If you are a seasoned JavaScript developer then you know that sometimes, it is completely different from other programming languages we are used to. For example, a function can be used as a mechanism to execute a piece of code in an isolated context or a way to create objects. The weird thing is, in both the cases, function definition looks similar, it’s up to the compiler how it treats it.

In this article, we are going to focus exactly on creating objects by using functions. A function that is used, to create objects is called a constructor function. In JavaScript, almost everything is an object. Let’s understand it.

Almost everything is an object

JavaScript has Primitive Data types and Reference Data types. number, string, boolean, symbol, null, and undefined are primitive data types. Primitive data type means when you create a variable, store a value of any given primitive data type in it, then declare another variable which is assigned (with the value) to the first variable, the second variable receives…

--

--