---
title: "Discussion on \"What the heck does \"new\" operator in JS do?\" | Hashnode"
description: "Discussion on \"What the heck does \"new\" operator in JS do?\". All of must have written this code in Javascript\nlet person = new Person(\"Eren Yeager\", 19);\n\nAnd we all know that we get a person object and voila! Now we can access properties/ methods on it.\nperson.age //19\nperson.name //Eren Yeager\nperson.transfo..."
url: "https://hashnode.com/posts/what-the-heck-does-new-operator-in-js-do/60e97cc96d962b01bdecbed9"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [What the heck does "new" operator in JS do?](https://munish.hashnode.dev/what-the-heck-does-new-operator-in-js-do?utm_source=hashnode&utm_medium=feed)

All of must have written this code in Javascript let person = new Person("Eren Yeager", 19); And we all know that we get a person object and voila! Now we can access properties/ methods on it. person.age //19 person.name //Eren Yeager person.transfo...

Jul 10, 2021 · 3 min read · munish.hashnode.dev  
Updated Oct 19, 2021  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#coding](https://hashnode.com/tag/coding)

## Written by

[Munish Thakur](https://hashnode.com/@munish710)

@munish710 · Chandigarh, India

  
[View profile](https://hashnode.com/@munish710)

For the love of building!

## Responses 1

Markdown supported · ⌘↵ to post

[Ankur Rajput](https://hashnode.com/@rajputankur023)

[Jul 10, 2021](https://hashnode.com/posts/what-the-heck-does-new-operator-in-js-do/60e97cc96d962b01bdecbed9/comment/60e9e7e3c551f16b0f848683)

This is really good.

There is only one exception in the returned value that I am aware of. If the constructor function returns an object then instead of the newly created object that object will be returned. The return statement will be ignored if it is of a primitive type.

[Munish Thakur](https://hashnode.com/@munish710)

[Jul 11, 2021](https://hashnode.com/posts/what-the-heck-does-new-operator-in-js-do/60e97cc96d962b01bdecbed9/comment/60e9e7e3c551f16b0f848683#reply-60ea9761c551f16b0f84a1b2)

Hi Ankur you are absolutely right. I mentioned about the non-null object, but intentionally dropped the primitive value return as that would surely confuse beginners, but I think i should add it for the sake of completeness.
