object.prototype javascript 确实删除了新对象

object.prototype javascript does delete new object

http://codepen.io/haikudoichi/pen/OPYBQN

除了删除选项外,一切似乎都正常。当我点击圆形对象时,我希望能够删除它。然而,它的表现很时髦。

这是正确的吗?

var sqrt = Math.sqrt((this.x - x)^2 + (this.y - y)^2);

"^" 不起作用,试试这个:

var sqrt = Math.sqrt(((this.x - x) * (this.x - x)) + ((this.y - y) * (this.y - y)));

我想你想这样做:

var sqrt = Math.sqrt(Math.pow(this.x - x, 2) + Math.pow(this.y - y, 2));

^ 是按位异或运算符。