Proposal: allow primitives to be explicitly returned from constructors

Isiah Meadows isiahmeadows at
Thu Apr 19 22:49:54 UTC 2018

Here's my proposal:

In constructors, currently, non-objects are replaced with `this`.
Here's what I think it should be replaced with:

1. When calling the constructor, if `undefined` is returned and
`` is not `undefined`, return `this` instead. This is for
compatibility and ease of implementation.
1. When calling the constructor, if anything else is returned, return
that value in raw form.

I know this is very *likely* very breaking, but I wonder if it would
be possible.

In case you're curious what this would change in the spec, it would
change [section 9.2.2][1], step 13.a-13.c to this:

a. If result.[[Value]] is not `undefined`, return
b. If kind is `"base"`, return NormalCompletion(thisArgument).



Isiah Meadows
me at

Looking for web consulting? Or a new website?
Send me an email and we can get started.

More information about the es-discuss mailing list