I know this is not the recommended way of doing it, but if I declare the following functions, and then invoke them as constructors, what will be the difference (if any) betw
In the second case, the returned object doesn't inherit anything from the constructor, so there's little point in using it as such.
> var x = new Something();
> var y = new something2();
> var z = something2();
I.e. what will differ between x, y and z here?
x inherits from Something, wheres neither y or z inherit from something2.
Wouldn't something2 be a much better way of writing the constructor, since whether you use new or not will not affect the result of the function?
There is no point in calling something2 as a constructor because the object it returns isn't the newly constructed object assigned to its this that inherits from something2.prototype, which is what others might expect to get when calling new something2().
BTW should something2 be capitalized here? (I assume not since Crockford is so adamant on the capitalization, for functions will clobber the global namespace...)
No, because calling it as a constructor is a bit pointless, so characterising it as one would be misleading.