Object-Oriented JavaScript ES6

Akiko Green
4 min readAug 27, 2020
Image source from codeburst.io

What exactly is Object-Oriented Javascript?

The best way to understand OOJS is that the objects in our code are what we use as models to represent the real world people, place, & things, to then plug those models into our program to solve real-world problems. Like our object, people contain “data”, and what I mean by that is, they have a name, age, sex, height, weight, occupation.. etc. OOJS gives us the ability to use the information from the model to emulate the behaviors and functionalities from that model, to then create data for us (programmers)to use in our application!

An example of our ‘Person’ object model:

class PersonName[firstName, lastName]
Age
Gender
Interests
Bio{"[Name] is ["Age"] years old. They like ["interests"]"}
Greeting{"Hi! My name is [Name]"}

Classes

What are classes?

No, I’m not referring to the classes in school! In terms of Javascript, classes are a “special function”. Think of the class function as an info card that a person can fill out about themselves.

Example class function via VsCode

Constructors

What are constructors?

A constructor is another special function in Javascript that defines and initializes objects and their features. They are useful because they provide an effective way of creating as many objects as you please, along with attaching data and function if need be!

--

--

Akiko Green

Software Engineer, Novice Blogger, Indoor Climbing Cutie 🥰