— I think the object literal was likely from older code that was refactored
— Tbh this really annoys me about JS... an undecidable you can only figure out by looking at integrations of the function
Message permanent page
— Unless you use ES6 classes
— It's if you want to return the API instead of object itself
— So you misuse it, i think. or i dont understand something
— I quickly checked myself just now, and yep
—
dgloredglore-mbp ~ node
> function Test() {
... return {p:1}
... }
undefined
> Test()
{ p: 1 }
> Test().constructor
[Function: Object]
> new Test()
{ p: 1 }
> (new Test()).constructor
[Function: Object]
> (new Test()).constructor === Test
false
Message permanent page