kdrnic/box2dweb

js bad practice

Closed this issue · 2 comments

Using Box2dWeb-2.1a.2.js

On line 2498:

      for (var each in __this.m_moveBuffer) {

__this.m_moveBuffer is an Array.  You should not use 'for ... in' with Array in 
js - if you extend the Array prototype (a common practice) then this code will 
break.

Instead, the code could read:

for (var each = 0; each < __this.m_moveBuffer.length; each++) {

I don't know if this error appears other places in the codebase, but this is 
the one that's breaking my code right now.

Original issue reported on code.google.com by congy...@gmail.com on 21 Apr 2011 at 1:37

This was already fixed by revision r24

Original comment by Uli.He...@googlemail.com on 21 Apr 2011 at 1:47

  • Changed state: WontFix
Sorry, didn't see that issue when searching.

I guess I'll just have to stop augmenting the Array prototype till the next 
release.

Original comment by congy...@gmail.com on 21 Apr 2011 at 2:17