【问题标题】:object.prototype javascript does delete new objectobject.prototype javascript 确实删除了新对象
【发布时间】:2015-04-07 23:24:12
【问题描述】:

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

除了删除选项外,一切似乎都在工作。当我单击圆形对象时,我希望能够将其删除。但是它的表现很时髦。

这对吗?

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

【问题讨论】:

  • 你能扩展一下“acting funky”吗?

标签: javascript object constructor prototype


【解决方案1】:

我想你想这样做:

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

^ 是按位异或运算符。

【讨论】:

  • 谢谢,我应该知道/知道的。接受以前的答案,因为它发布得更快
【解决方案2】:

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

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

【讨论】:

    猜你喜欢
    • 2010-12-15
    • 2023-03-05
    • 2017-04-05
    • 1970-01-01
    • 1970-01-01
    • 2018-07-25
    • 1970-01-01
    • 2010-10-19
    • 2018-04-20
    相关资源
    最近更新 更多