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 =
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
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
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
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,
5 matches
Mail list logo