More specifically, for a random class with two public properties, in C# you can do something like this :
new Point() {
Y = 0,
X = 0
}
Is it possible to do something similar in JavaScript? I was thinking of something along the line of :
{
prototype : Object.create(Point.prototype),
X : 0,
Y : 0
}
but I don't think it works as intended. Or a simple copy function :
function Create(object, properties) {
for (p in properties)
object[p] = properties[p];
return object;
}
so the object initialization would become :
Create(new Point(), {X : 0, Y : 0});
but there is an extra object creation. Is there a better way of achieving this?