2

I've seen a number of questions about new Object vs new Object() or new Object() vs {}, but I'm wondering about what the difference is between Object() and new Object()? In other words, what's the difference between calling the Object constructor with new vs not?

I've seen one other answer here on StackOverflow, but it's in regards to ES5. I'm wondering about for ES6?

I also ask because MDN on their page for the Object() constructor states:

Note: Object() can be called with or without new, but sometimes with different effects. See Return value.

But under the "Return value" section on that page, I cannot discern what these "different effects" may be?

6
  • 2
    This did not change with ES6 afaik. I'm tempted to close the question as a duplicate.
    – Bergi
    Commented Aug 27, 2023 at 21:32
  • At best, they removed the section about special-casing host objects that no implementation was actually using. Did you check the ES6 spec yourself already?
    – Bergi
    Commented Aug 27, 2023 at 21:33
  • "I cannot discern what these "different effects" may be?" - probably those that are mentioned in the answer to the question you linked - which are none in practice.
    – Bergi
    Commented Aug 27, 2023 at 21:34
  • 2
    According to the current spec, the return values are not different — they both result in an ordinary object when invoked without an argument. Prefer neither (unless you're programming functionally) and instead use a new object literal: const obj = {};.
    – jsejcksn
    Commented Aug 27, 2023 at 22:40
  • 1
    @mishar In that case, you might want to post an answer and file an issue for MDN
    – Bergi
    Commented Aug 28, 2023 at 0:25

0