seajean / box2dweb

Automatically exported from code.google.com/p/box2dweb
0 stars 0 forks source link

js bad practice #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
This was already fixed by revision r24

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

GoogleCodeExporter commented 9 years ago
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