>
> 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,


"use strict"

function SomeConstructor(params) {
    this.pollute = params
}

Just use use strictmode so that your constructor throws an error if it's
called without new

The instanceof check is considered friendly for the purpose of your API
being agnostic of `var o = SomeConstructor(...)` and `var o = new
SomeConstructor(...)`

-- 
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