Javascript — Revisiting Core Topics

On one of my previous posts, we dived in to the topic of asynchronous vs synchronous. This week, we’ll look at a few other core topics and refresh our knowledge of Javascript.

Classes & Object

According to MDN Web Docs, classes are are a template for creating objects. They encapsulate data with code to work on that data. Classes are considered “special” functions, and just as you define regular functions, classes have expressions and declarations. Class declaration is simple and straight forward, where you use the “class” keyword along with the name of the class (i.e. Engineer). Below is how we would go about declaring a class.

Class expression is just another way to define a class. They can be named or unnamed. If we leave it unnamed, it would just refer back the original name we gave the class.

Setting up our classes is like creating a template or blueprint for our future objects. By using the constructor method we are able to create properties for the class. In the example above, we are able to create the name, favorite language and number properties for the engineer class. With the properties set in place, we can now create objects with property values.


Whenever we create a class, “this” is often use to in reference to the class itself. So what is “this”? Usually, Javascript’s “this” refers to the object it belongs to, but “this” can change depending on the context or situation it is used in.

When “this” is used alone in the a global context or in a function, the owner is the global object. Meaning “this” is referring to its owner, the global object.

When “this” is used in a method, it is referring to the owner of the method.

Software Engineer