Re: Create a new native object with a constructor
Boris Zbarsky <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
On 6/19/16 9:05 PM, Braden McDaniel wrote: > What's the modern way to create a new native object that has a > constructor? Has a constructor in what sense? Do you mean that there is a JSNative constructor that you want to get called that creates the object? Or that you create the object but then call the JSNative on it? Something else? > The preferred alternative is to save a copy of the constructor > function for the class, then to call it using JS_New. > > But that doesn't look like the right answer for a natively implemented > object (since JS_NewObject still does look like part of the answer for > natively implemented objects). This comes back to my question above. If the constructor JSNative creates the object, then just calling it via JS_New will do the right thing; it'll do the JS_NewObject itself. -Boris