Message from JavaScript discussions

October 2018

— Etc

— 

In terms of my needs I will turn it into a more typical constructor though, since you reminded me it is not cached haha

— 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 was wrong

— Haha

— 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