I'm given an instance "aNode" of a prototype called "Node". Following this discussion, I attempt to:
var newNode = clone(aNode);
The clone function goes like:
function clone(obj) {
if (null == obj || "object" != typeof obj) return obj;
var copy = obj.constructor();
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr];
}
return copy;
}
Despite obj.consturctor() properly refers to aNode's constructor, copy is "underfined". Can't find why :(
Is this method wrong, or am I missing something :) ?
Thanks, J.
Edit: here is what the Node prototype looks like:
Node.prototype = new PhysicsNode();
Node.prototype.constructor=Node;
function Node() {
PhysicsNode.call(this);
this.setBounds(0, 0, 0, 0);
this.createStaticBody();
}