Preventing instance extension

2011-11-11 Thread Axel Rauschmayer
Having recently bitten by a mistyped property name (see code underneath signature), I think I might prevent the extension of instances more often. But what is the best way of doing so? Variant 1: prevents subtyping the constructor function Point(x, y) { this.x = x; this.y =

Re: Preventing instance extension

2011-11-11 Thread Xavier MONTILLET
Object.getPrototypeOf(this) === Point.prototype = this instanceof Point And I don't understand your problem _ On Fri, Nov 11, 2011 at 8:11 PM, Axel Rauschmayer a...@rauschma.de wrote: Having recently bitten by a mistyped property name (see code underneath signature), I think I might prevent

Re: Preventing instance extension

2011-11-11 Thread Juan Ignacio Dopazo
On Fri, Nov 11, 2011 at 4:23 PM, Xavier MONTILLET xavierm02@gmail.com wrote: Object.getPrototypeOf(this) === Point.prototype = this instanceof Point Actually, no. this instanceof Point = Object.getPrototypeOf(this) === Point.prototype, but not the other way around. And I don't

Re: Preventing instance extension

2011-11-11 Thread Xavier MONTILLET
And why can't you call the superconstructor at the end? It'd work the exact same except it could overwrite some of the properties you wrote... but since those things would more likely be in prototype, it's not much of an issue. On Fri, Nov 11, 2011 at 10:05 PM, Juan Ignacio Dopazo

Re: Preventing instance extension

2011-11-11 Thread Axel Rauschmayer
And why can't you call the superconstructor at the end? It'd work the exact same except it could overwrite some of the properties you wrote... but since those things would more likely be in prototype, it's not much of an issue. That is definitely a possibility! It does have one drawback,