JavaScriptEasy
Difference between: function Person(){}, const person = Person(), and const person = new Person() in JavaScript?
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
function Person(){}: A function declaration in JavaScript. It can be used as a regular function or as a constructor.const person = Person(): CallsPersonas a regular function, not a constructor. IfPersonis intended to be a constructor, this will lead to unexpected behavior.const person = new Person(): Creates a new instance ofPerson, correctly utilizing the constructor function to initialize the new object.
| Aspect | function Person(){} | const person = Person() | const person = new Person() |
|---|---|---|---|
| Type | Function declaration | Function call | Constructor call |
| Usage | Defines a function | Invokes Person as a regular function | Creates a new instance of Person |
| Instance Creation | No instance created | No instance created | New instance created |
| Common Mistake | N/A | Misusing as constructor leading to undefined | None (when used correctly) |
