I am sure you must have been through the basics of JavaScript.By now, you might know that arrays, functions, objects, dates are all objects.JavaScript is a prototype-based language which means that inheritance works by something called prototypes. Each and every object in JS has a prototype property.

OK, now enough if the fuss about prototypes 😅 , let’s understand it.

The usual function constructor approach

As you might be aware of the function constructor approach in JS to create objects so we are going to create a function constructor as such:

var Person = function(name,yearOfBirth,job) { this.name = name; this.yearOfBirth = yearOfBirth; this.job = job…


Coercion is one of the weird parts of Javascript and has time and again confused many newbies and even developers when the came across it.Also, trick concepts like these continue to remain a hot topic in developer interviews.So without much further ado, let’s dive into it and get to know it better.

What is Coercion?

Coercion is the unexpected type casting in JavaScript.Often when working with JavaScript we come across situations involving typecasting data from one data type to another.Coercion refers to the typecasting you wouldn’t believe would happen at first go! .

Some people consider this as a flaw in JavaScript but…

Aakash Garg

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store