Proposal: allow primitives to be explicitly returned from constructors

Oriol _ oriol-bugzilla at
Thu Apr 19 23:22:35 UTC 2018

This would break one of my most preferred ways to check whether a value is an object:

function isObject(value) {
  return value === new function(){ return value };

Unlike `Object(value) === value`, the above is just syntactic, it does not require `Object` to be the built-in one.

And I don't really see the point, constructors are supposed to construct objects. If you want primitives, you can always use function calls.

-- Oriol

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list