Member-only story

Javascript Classes: Javascript Interview Questions (EcmaScript 6)

Melih Yumak
3 min readJun 13, 2022

--

Javascript

Javascript Interview Questions # 3

What is javascript classes? How can we use javascript classes?

Hello everyone, in this tutorial we will learn about javascript classes and example usages of javascript classes.

With the help of ES6 in the javascript we can start using class keyword in our code. Classes introduced to javascript with ES6.

What is class in javascript?

You can think about classes are template for creating objects. To create an object you can use classes.

We can think about creating object with similar or different properties with classes.

For example lets think about creating a User class. The properties we define for the user can be change like firstName, lastName, email, age, username etc. When we define our User class we can create multiple objects with passed different properties.

Creating Constructor Function BEFORE ES6

Classes are very similar to constructor function. It has used syntatic sugar as difference.

If we wanted to create User object with constructor function it would be as following.

--

--

Melih Yumak
Melih Yumak

Written by Melih Yumak

Top Technology Writer — Lead Full Stack Software Engineer — Youtuber https://www.youtube.com/c/TechnologyandSoftware

Responses (1)