> The way you're doing it is exactly right.  The "instanceof" guard is
> sadly necessary, since there's no way to specify that a function may
> *only* be called as a constructor in JS, and calling it without new
> will then pollute the global namespace, and there'll be a reward on
> your head for $NaN.

I'd vote for throwing an Error or even process.exit() as guard instead
of silently repairing behind the scenes what was done wrong, so the
caller is eventually cleaned up. But I suppose thats a matter of
taste. At least in in my own userland core, I like to rather force
myself to be tidy.

BTW: jshint complains by default when calling a function without new
that starts with an uppercase letter.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to