This is a continuation of the post from last week on object-oriented programming.

The four pillars are the most important concepts behind object-oriented programming. Here is a short explanation of two of them. The other two will be covered in the next article.


Abstraction is the concept of only exposing relevant methods and data to user of object. All of the details of the implementation of the object are hidden unless they need to be seen or used by the user. This can greatly simplify a codebase.

Here is an example:

The logic of the rehome method is abstracted away from the user. They simply interact with it by calling the method.

By the way, functions are just special types of objects in JavaScript, and, since there are no classes in the language, we can use functions to create objects instead.


This is a concept we are already familiar with from nature: children inherit genes from their parents. In programming, objects or classes can inherit characteristics from parent objects or classes.

Here is an example:

You can think of the Animal constructor function here as a template to create other objects or inherit into other constructor functions. Properties and methods from Animal can be used, overwritten, or extended by Cat. This helps to maintain reusable, DRY (don't repeat yourself), code throughout your codebase.


I hope you enjoyed this article. Please let me know your thoughts in the comments below.

This series will be continued next week with an article on the final two pillars of OOP. See you then.