Object.freeze(YourConstructor.prototype)
can help protect your constructor's associated prototype object from being mucked with. From MDN:
The Object.freeze()
method freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed, it also prevents the prototype from being changed.
It works on the object itself, rather than making a copy that's frozen. It returns the same reference you pass it.
It's best to leave built-in prototypes alone, so using it on Object.prototype
and such may not be a great idea. :-) Certainly you'd need to do a lot of testing if you did... See this thread on the es-discuss mailing list for relevant, useful info.