Finding a "safety syntax" for classes

Domenic Denicola domenic at
Tue Mar 27 10:41:18 PDT 2012

On Mar 27, 2012, at 13:10, "David Herman" <dherman at> wrote:

> I recognize the C.prototype.constructor idiom already exists, but it's a weak idiom. I'm not crazy about the idea of strengthening a problematic but currently unreliable and rarely used idiom.
> Dave

Speaking as a dev, I would like this idiom to be stronger (i.e. be there by default in a classy world). One use case that immediately springs to mind is try { } catch (e) { switch(e.constructor) { } }, which we've used a couple times in the absence of Mozilla-style exception guards.

Your concern about possibly not wanting to expose the constructor makes a lot of sense, but perhaps we could leave .prototype.constructor configurable and let people in such a situation explicitly delete it.

More information about the es-discuss mailing list