Category:

Understanding JavaScript’s object oriented programming system can be difficult, especially if your background is in a language that uses a class-based system such as Python, Java, or C++. I can remember being incredibly frustrated trying to understand how objects, prototypes and constructor functions work together when I first started out in JavaScript. This blog post is meant to be the guide that I never had back then. In it, I’ll introduce the key concepts in JavaScript’s prototype-based OOP system, hopefully addressing some of the confusion surrounding it.

Objects in JavaScript

Javascript has six primitive types as specified in ECMAScript 2015: undefined, null, boolean, number, symbol, and string. Everything else is an object. Objects are collection of key-value pairs called properties. An object can be created by enclosing colon-separated keys and values in curly braces, and is called an object literal. Here’s an example:

Read More …