admin管理员组文章数量:1289583
I came across this looking at the source for some physics animations in JavaScript found here on github where he's written this
if (this._position < 0) this._position /= 3;
A quick Google yielded nothing, anyone know?
I came across this looking at the source for some physics animations in JavaScript found here on github where he's written this
if (this._position < 0) this._position /= 3;
A quick Google yielded nothing, anyone know?
Share Improve this question edited Feb 13, 2016 at 13:43 Tushar 87.2k21 gold badges163 silver badges181 bronze badges asked Feb 13, 2016 at 13:37 bigmadwolfbigmadwolf 3,5393 gold badges31 silver badges47 bronze badges 3- 2 Shorthand division operator. – Tushar Commented Feb 13, 2016 at 13:37
- 2 Called a 'Division/Assignment Operator': It does a divide then assigns the value. Details here: developer.mozilla/en-US/docs/Web/JavaScript/Guide/… – Jeremy J Starcher Commented Feb 13, 2016 at 13:38
- so this means "if the position is less than zero, make position equal to position divided by three"...? – bigmadwolf Commented Feb 13, 2016 at 13:39
3 Answers
Reset to default 11The operator is shorthand division operator. It is equivalent to
this.position = this.position / 3;
The division will be performed first and then the result will be assigned to the dividend.
Quoting from MDN
The division assignment operator divides a variable by the value of the right operand and assigns the result to the variable.
It's the division equivalent of +=
or -=
This is a division asignment operator: This performs the following operation: Ex:
var x=10,y=2;
x=x/y;
/*
which is equivalent to x/=y;
and returns 5
*/
本文标签: What does 3939 operator mean in JavaScriptStack Overflow
版权声明:本文标题:What does '=' operator mean in JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741447819a2379306.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论