Subj : Re: Preventing 'new' To : Jamie Nordmeyer From : Brendan Eich Date : Fri Mar 25 2005 02:36 pm Jamie Nordmeyer wrote: > How do you hide an object's constructor so that you can't 'new' that object? > Essentially, I want to be able to create the object in my C++ code, but the > Javascript user should NOT be able to. They should have to do the > following: > > var objB = objA.CreateObjB(); Why do you want to require that? If you don't want a constructor, don't define one. You can pass null as the |constructor| parameter to JS_InitClass, and you'll get the class's prototype object named by the class's name in the global object, instead of a constructor function with a property named 'prototype' referencing the class prototype. /be .