Classes are functions, which are also objects, so that's not incorrect to say they're objects. But yes, you can pretty much recreate the functionality provided by classes with ordinary functions and objects. What classes provide is a cleaner, (often) simpler syntax for defining the structure and behavior for your custom objects. With more recent versions of JavaScript classes can also do some other things not possible outside of classes like define private properties. The again it's not too hard to get similar functionality through alternative means. For your Rectangle class, that could instead have been written as the non-class constructor function function Rectangle(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; this.area = height * width; } Or if taking the factory route, it would look something more like function Rectangle(height, width) { return Object.setPrototypeOf({ name: "Rectangle", width, height, area: height * width }, Rectangle.prototype) } In particular, classes let you take advantage of prototypes without directly exposing you to them. While your example doesn't have a method, if we converted area over to one, you'll start to see some of the convenience of the syntax coming through class Rectangle { constructor(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; } area() { return this.width * this.height; } } vs function Rectangle(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; } Rectangle.prototype.area = function() { return this.width * this.height; } Answer from senocular on reddit.com
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Classes
Classes - JavaScript | MDN
May 22, 2026 - Classes are a template for creating objects. They encapsulate data with code to work on that data. Classes in JS are built on prototypes but also have some syntax and semantics that are unique to classes.
🌐
W3Schools
w3schools.com › js › js_classes.asp
JavaScript Classes
JavaScript Classes are templates for JavaScript Objects. Use the keyword class to create a class. ... The example above creates a class named "Car". The class has two initial properties: "name" and "year".
Discussions

Are JavaScript classes just objects with a prettier name and usability?
Classes are functions, which are also objects, so that's not incorrect to say they're objects. But yes, you can pretty much recreate the functionality provided by classes with ordinary functions and objects. What classes provide is a cleaner, (often) simpler syntax for defining the structure and behavior for your custom objects. With more recent versions of JavaScript classes can also do some other things not possible outside of classes like define private properties. The again it's not too hard to get similar functionality through alternative means. For your Rectangle class, that could instead have been written as the non-class constructor function function Rectangle(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; this.area = height * width; } Or if taking the factory route, it would look something more like function Rectangle(height, width) { return Object.setPrototypeOf({ name: "Rectangle", width, height, area: height * width }, Rectangle.prototype) } In particular, classes let you take advantage of prototypes without directly exposing you to them. While your example doesn't have a method, if we converted area over to one, you'll start to see some of the convenience of the syntax coming through class Rectangle { constructor(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; } area() { return this.width * this.height; } } vs function Rectangle(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; } Rectangle.prototype.area = function() { return this.width * this.height; } More on reddit.com
🌐 r/learnjavascript
17
6
March 23, 2023
JS classes vs JS objects?
An object is an instantiated class. A class is a blue print, the object is the item. unless you add some static functions, you can't use class without creating objects of them. static functions are shared across the objects. If you add some member to it you can set a var for all the objects. More on reddit.com
🌐 r/learnjavascript
23
7
March 4, 2019
class - Are classes necessary in Javascript? What effect do they have on creating objects? - Stack Overflow
That's true. Thanks for testing and your answer! 2019-10-09T09:43:18.88Z+00:00 ... Save this answer. ... Show activity on this post. Is there a difference between these two kinds of objects? If so, what effect does it have to use class explicitly? More on stackoverflow.com
🌐 stackoverflow.com
Constructors in objects created with classes
Do objects created with classes always come with constructors? Your code so far // Only change code below this line // Only change code above this line const carrot = new Vegetable('carrot'); console.log(carrot.name); // Should display 'carrot' Your browser information: User Agent is: Mozilla/5.0 ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
4
0
August 17, 2021
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › classes-and-objects-in-javascript
Classes and Objects in JavaScript - GeeksforGeeks
February 13, 2026 - For example, the animal type Dog is a class, while a particular dog named Tommy is an object of the Dog class. A class in JavaScript is a blueprint used to create objects that share similar properties and methods.
🌐
Reddit
reddit.com › r/learnjavascript › are javascript classes just objects with a prettier name and usability?
r/learnjavascript on Reddit: Are JavaScript classes just objects with a prettier name and usability?
March 23, 2023 -
class Rectangle {
  constructor(height, width) {
    this.name = "Rectangle";
    this.height = height;
    this.width = width;
    this.area = height * width;
  }
}

console.log(new Rectangle(4, 3).area);

This, to me, just looks as an object called Rectangle, which has a method called constructor with two parameters height and width . Couldn't have done the same with an object constructor?

Top answer
1 of 3
16
Classes are functions, which are also objects, so that's not incorrect to say they're objects. But yes, you can pretty much recreate the functionality provided by classes with ordinary functions and objects. What classes provide is a cleaner, (often) simpler syntax for defining the structure and behavior for your custom objects. With more recent versions of JavaScript classes can also do some other things not possible outside of classes like define private properties. The again it's not too hard to get similar functionality through alternative means. For your Rectangle class, that could instead have been written as the non-class constructor function function Rectangle(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; this.area = height * width; } Or if taking the factory route, it would look something more like function Rectangle(height, width) { return Object.setPrototypeOf({ name: "Rectangle", width, height, area: height * width }, Rectangle.prototype) } In particular, classes let you take advantage of prototypes without directly exposing you to them. While your example doesn't have a method, if we converted area over to one, you'll start to see some of the convenience of the syntax coming through class Rectangle { constructor(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; } area() { return this.width * this.height; } } vs function Rectangle(height, width) { this.name = "Rectangle"; this.height = height; this.width = width; } Rectangle.prototype.area = function() { return this.width * this.height; }
2 of 3
3
There are two ways to stamp new objects. Class, or Factory function. Class acts like a template for all objects that you created it with and when you change the class itself then the objects change too even though you already created them. Factory function just spits out a new object each time and isn't connected to it, so when you change the factory function all the objects don't care about it. At least that's how I remember it. Factory function can be better than class in certain moments and shenanigans with this.
🌐
Medium
medium.com › @sasindran.anusha › mastering-javascript-classes-a-deep-dive-into-modern-object-oriented-programming-0de6b8e7b221
Mastering JavaScript Classes: A Deep Dive into Modern Object-Oriented Programming | by Anusha Sasindran | Medium
August 12, 2024 - Classes are a template for creating objects. They encapsulate data with code to work on that data. Classes in JavaScript are built on prototypes but also have some syntax and semantics that are not shared with ES5 class-like semantics.
🌐
CodeSignal
codesignal.com › learn › courses › javascript-classes-and-objects-basics › lessons › javascript-classes-in-object-oriented-programming
JavaScript Classes in Object-Oriented Programming
A JavaScript class serves as a blueprint consisting of properties and methods. While properties represent data relevant to a class instance, methods are actions or functions that manipulate this data. Each class includes a constructor function, which is used to define class properties.
Find elsewhere
🌐
Codecademy
codecademy.com › forum_questions › 52b0d81180ff33e586000084
What is the difference between an Object and a Class | Codecademy
A Class is a special function used for ‘instantiating’ objects that share the same set of properties. This way we define our class once, and can instantiate as many different objects as we need, all using the same ‘template’, as it were.
🌐
Boldare
boldare.com › blog › how-to-use-javascript-classes
JavaScript Classes - How to Use Them? 3 JS Class Methods | Boldare
March 21, 2019 - That means that it can’t be invoked by the instance of the class. Furthermore, static methods can also be inherited and can be invoked from subclasses. You’ll also notice a new word “super” in the constructor. The super keyword is used to access and call functions from an object’s parent. Additionally, you need to remember that the constructor can be used before the “this” keyword is used. Let’s wrap this article up. By and large, we can’t say with a clear conscience that JavaScript classes exist because the whole mechanism is based on prototypes.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object
Object - JavaScript | MDN
May 22, 2026 - It is used to store various keyed collections and more complex entities. Objects can be created using the Object() constructor or the object initializer / literal syntax. Nearly all objects in JavaScript are instances of Object; a typical object inherits properties (including methods) from Object.prototype, although these properties may be shadowed (a.k.a.
🌐
Readthedocs
jfine-python-classes.readthedocs.io › en › latest › javascript-objects.html
JavaScript objects — Objects and classes in Python tutorial
JavaScript objects are like Python classes with custom item methods (on the metaclass) that are never instantiated.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Working_with_objects
Working with objects - JavaScript | MDN
For more information, see the class guide. Objects can also be created using the Object.create() method. This method can be very useful, because it allows you to choose the prototype object for the object you want to create, without having to define a constructor function. ... // Animal properties and method encapsulation const animalProto = { type: "Invertebrates", // Default value of properties displayType() { // Method which will display the type of animal console.log(this.type); }, }; // Create a new animal type called `animal` const animal = Object.create(animalProto); animal.displayType(); // Logs: Invertebrates // Create a new animal type called fish const fish = Object.create(animalProto); fish.type = "Fishes"; fish.displayType(); // Logs: Fishes
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Using_classes
Using classes - JavaScript | MDN
JavaScript is a prototype-based language — an object's behaviors are specified by its own properties and its prototype's properties. However, with the addition of classes, the creation of hierarchies of objects and the inheritance of properties and their values are much more in line with ...
Top answer
1 of 5
5

Using new creates a new object whose internal prototype is the class's prototype. For example:

class Test {
    say() {
        console.log("I'm a test.");
    }
}

let TestFromClass = new Test();
console.log(Object.getPrototypeOf(TestFromClass) === Test.prototype);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

This is useful for creating multiple objects. The usual reason to do this is so that each object can have some sort of associated state - generally, the values of its properties. For example, a Person object might have a name and an age property.

However, if there is no data to associate with an instance (as with TestFromClass in the original code), there's not much point having an instance at all. The TestFromObject approach makes much more sense if the purpose is just to collect named functions into a data structure.

That said, it's sometimes desirable to have a class that has some functions associated with it (like say) which don't have anything to do with an instance of its data, while still being able to create an instance - perhaps using other methods on the prototype. This isn't that uncommon, and is done by making the non-instance-related functions static:

class Person {
  static canEat() {
    return ['apples', 'bananas', 'carrots'];
  }
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }
}
const p = new Person('Bob', 99);
console.log(p.name);
console.log(Person.canEat());
Run code snippetEdit code snippet Hide Results Copy to answer Expand

2 of 5
2

A class is more or less just syntactic sugar for a prototype:

// The class way
class Test {
  say() {
    console.log("I'm a test.");
  }
}


// The old fashioned way
function Test() {

}

Test.prototype.say = function () {
  console.log("I'm a test.");
};

The difference in both these cases with direct object creation is that the methods belong to the prototype, not directly to the object.

The code TestFromClass.say() must go through the prototype chain to find a say method, while TestFromObject directly has the method.

Other than that, there's no difference.

🌐
LinkedIn
linkedin.com › pulse › understanding-objects-classes-javascript-comparison-f-ribeiro
Understanding Objects and Classes in JavaScript: A comparison and Overview
August 13, 2023 - It seems that the main difference ... is that classes are a syntactical addition to the language introduced in ECMAScript 2015 (ES6) to provide a more structured and familiar way of defining objects and their behavior...
🌐
Medium
medium.com › @markmiro › thoughts-on-choosing-between-plain-js-objects-and-classes-6422af8aaad5
Thoughts on choosing between plain JS objects and classes. | by Mark Miro | Medium
January 11, 2019 - It’s possible that a pro/con analysis of classes will always lead you to use plain JS objects. However, depending on the kind of code you write, a class might be the right tool for the job. This post is a collection of thoughts around when to use one vs. the other. One of the classic benefits of classes is that they allow you to keep the data and code that operates on that data together.
🌐
Codecademy
codecademy.com › forum_questions › 4f51465ec31cb8000301fe2c
Does JavaScript have Classes? | Codecademy
I can say for sure that JS treats functions as first class objects (i.e., they can be passed around just like a variable can be). This basically means that functions are objects, which in turn means there is very little difference (if any) between a function and a class.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-classes-in-javascript-handbook
How to Use Classes in JavaScript – A Handbook for Beginners
February 23, 2025 - Instead of classical classes as found in languages like Java or C++, JavaScript is built on something called prototypes*.* It uses these flexible prototypes and objects to mimic how classes work in other languages.
🌐
freeCodeCamp
forum.freecodecamp.org › programming › javascript
Constructors in objects created with classes - JavaScript - The freeCodeCamp Forum
August 17, 2021 - Do objects created with classes always come with constructors? Your code so far // Only change code below this line // Only change code above this line const carrot = new Vegetable('carrot'); console.log(carrot.name); // Should display 'carrot' Your browser information: User Agent is: Mozilla/5.0 ...
🌐
Codecademy
codecademy.com › forum_questions › 4f616d60a09c430003001219
Class vs. Object??? | Codecademy
Thus, a class can be seen either as a set of objects sharing common properties and methods, or as the set of common properties and methods available to all those objects.