Skip to content

Commit 1b87b89

Browse files
authored
Omitting parentheses after new
Parentheses can be omitted even if the constructor function has arguments: ```js new function(test) { return { test } } // Works the same as new (function(test) { return { test } })(); ```
1 parent ff4ef57 commit 1b87b89

File tree

1 file changed

+1
-1
lines changed
  • 1-js/04-object-basics/06-constructor-new

1 file changed

+1
-1
lines changed

‎1-js/04-object-basics/06-constructor-new/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ alert( new SmallUser().name ); // John
171171
Usually constructors don't have a `return` statement. Here we mention the special behavior with returning objects mainly for the sake of completeness.
172172

173173
````smart header="Omitting parentheses"
174-
By the way, we can omit parentheses after `new`, if it has no arguments:
174+
By the way, we can omit parentheses after `new`:
175175
176176
```js
177177
let user = new User; // <-- no parentheses

0 commit comments

Comments
 (0)