Yup, correct. The value of the `this` binding is initialized to the result of `[[Construct]]`, which will either be the parent constructor `this` binding, or the explicitly returned value.
Relevant spec links: Evaluating `super()`: (12.3.5.1) http://www.ecma-international.org/ecma-262/6.0/#sec-super-keyword-runtime-semantics-evaluation Returning a value from a constructor: (9.2.2 step 13.b) http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-construct-argumentslist-newtarget On Fri, Oct 16, 2015 at 2:24 PM, Eric Faust <[email protected]> wrote: > Hi Isiah, > > My understanding is that this should log "true". Class constructors may > return any object they wish, and needn't return instances of the class. > > Hopefully, this will allow you to simplify. > > Thanks, > > Eric > > On Fri, Oct 16, 2015 at 2:02 PM, Isiah Meadows <[email protected]> > wrote: > >> What should `this` be in class `B`? The value of `object` or an instance >> of `B`? It's an edge case, but could simplify my code a little if it's the >> former. >> >> ```js >> const object = {} >> >> class A { >> constructor() { >> return object >> } >> } >> >> class B extends A { >> constructor() { >> super() >> console.log(this === object) >> } >> } >> ``` >> >> _______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> >> > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

