Object Oriented Programming w/ JavaScript| “this”, “new” & constructors
Hi there, welcome to my first technical blog post! This is the start of a series where I explain concepts related to OOP (Object Oriented Programming) with JavaScript. If you don’t know what any of those words mean, that’s okay, but be sure to read through the next paragraph and check the free resources linked within to get a primer before reading the rest of the post! If you’re familiar already, feel free to skip the next section.
A quick primer
OOP is a programming paradigm, or a way of thinking about programming. In this way of thinking, websites and applications are built around objects.
In JavaScript, objects are variables that act as containers for data. Objects appear as a collection of key:value pairs like this example below:
Check out this resource for more on what OOP is & how it is used: https://www.techtarget.com/searchapparchitecture/definition/object-oriented-programming-OOP
“this”
You may have encountered the word “this” while reading JavaScript code. If you’re like me, you were probably super confused on the word and its meaning. “this” is a relative reference to the object it belongs to. The keyword makes your code more reusable and is very useful to learn!
As someone who loves languages and writing, viewing the technical term “this” in the same way I think about pronouns in English really helped me wrap my…