Re: JS 45 problem
Boris Zbarsky <[email protected]> Thu, 3 Nov 2016 20:30:51 -0400
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
On 11/3/16 5:18 PM, [email protected] wrote: > Out of curiosity, what's the advantage of using |JS_NewObjectWithGivenProto| over |JS_NewObjectForConstructor| within a constructor call? JS_NewObjectForConstructor (which I hadn't actually known about, fwiw) will always use callee's .prototype as the proto, falling back to Object.prototype if callee.prototype is not an object. The code I sent that used JS_NewObjectWithGivenProto was getting .prototype from the newTarget, not the callee. This only matters if your JSNative constructor is being subclassed in script. We should probably change JS_NewObjectForConstructor to play nice with subclassing; if we did that it would be the obvious thing to use here. -Boris