Constructors that produce frozen instances?

Axel Rauschmayer axel at
Sat Jun 8 20:22:19 PDT 2013

It’s difficult to do that if you want your constructors to remain subtypable. Is the following the best we can do? A constructor can only freeze if it is the first constructor that is invoked.

    function Point(x, y) {
        this.x = x;
        this.y = y;
        if (this.constructor === Point) {
    function ColorPoint(x, y, color) {, x, y);
        this.color = color;
        if (this.constructor === ColorPoint) {
    ColorPoint.prototype = Object.create(Point);
    ColorPoint.prototype.constructor = ColorPoint;

(More detailed write-up: )

Dr. Axel Rauschmayer
axel at


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

More information about the es-discuss mailing list