3 ms·
I generally write my constructor functions so I can easily forget 'new': function Point(x, y){ if (!(this instanceof Point)) { return new Point(x,
by 2mur 14y ago
I generally write my constructor functions so I can easily forget 'new':
function Point(x, y){
if (!(this instanceof Point)) {
return new Point(x, y);
}
this.x = x;
this.y = y;
}
then you can just call:
var point = Point(x, y);
HT to issacs (node, npm) who I picked that up from.
- ryankinal 14y agoGood workaround! I like it.