Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

Classes In JavaScript

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The new version of JavaScript (ES6) introduced the use of classes instead of functions. Prior to ES6, there were only classes and, functions which are callable objects. A class in javascript is basically a blueprint or template of the object. New objects can be created from a class. 

Class In JavaScript

Classes are similar to functions. Here, a class keyword is used instead of a function keyword. Unlike functions classes in JavaScript are not hoisted. The constructor method is used to initialize. The class name is user-defined.


class classname {
  constructor(parameter) {
    this.classname = parameter;

Example: The below example illustrates the JavaScript classes.


    class emp {
        constructor(name, age) {
   = name;
            this.age = age;
    const emp1 = new emp("Geek1", "25 years");


Geek1:25 years
My Personal Notes arrow_drop_up
Last Updated : 29 Sep, 2022
Like Article
Save Article
Similar Reads
Related Tutorials