Javascript 'new' with function returning self
This question already has an answer here:
In your particular instance, No, there is no difference.
Eitherw way, your function will return a self defined Object. By invoking a function with the new
keyword, ECMAscript will automatically create a new object for you (alongside doing some magic with prototype
and constructor
properties), which you might access / write to via this
within the function (-constructor)
.
Again, your return { }
call in that function, will always return exactly that object reference.