Differences between ES6 class and ES5 function constructors Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 9 Likes Like Report In this article, we will discuss the difference between the ES6 class and ES5 function constructors. Both serve the purpose of creating new objects, still, they have some differences between them. ES6 Class constructors: ES6 class constructors work quite the same as class constructors in other object-oriented languages. They are used to create new objects. JavaScript class User { constructor(name, age, gender) { this.name = name; this.age = age; this.gender = gender; } print() { console.log(`${this.name} has an age of ${this.age} and gender of ${this.gender}`); } } const Roy = new User('Roy', '19', 'Male'); Roy.print(); Output: "Roy has an age of 19 and gender of Male" ES5 function constructor: ES5 function constructors are also used to create objects. The above example can be modified as following through the use of function constructors. JavaScript function User(name, age, gender) { this.age = age; this.name = name; this.gender = gender; this.print = function () { console.log(`${this.name} has an age of ${this.age} and gender of ${this.gender}`); }; } const Roy = new User('Roy', '19', 'Male'); Roy.print(); Output: "Roy has an age of 19 and gender of Male" Difference between ES6 class and ES5 function constructors: ES6 class constructors ES5 function constructorsAs discussed above ES6 class constructors creates objects by adding function to their prototypes (Blueprint).ES5 function constructors also create objects along with inheritance property. It ensures that this keyword used by the developer is referring to the object being created by the developer. Any function can be used as a function constructor and it primarily focuses on the creation of reusable object creation code.Its syntax is similar to object creation in other object-oriented programming languages.Its syntax is unique and is not generally found in other object-oriented programming languages.This can be said to be a syntax base for constructor functions and instantiate objects using a new operator.This also uses a new operator for object creation but focuses on how the objects are being instantiated. Create Quiz Comment N namancourses Follow 9 Improve N namancourses Follow 9 Improve Article Tags : Difference Between JavaScript Web Technologies ES6 JavaScript-Questions Web Technologies - Difference Between +2 More Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like