Not mentioned is spatial hashing, which works well without complex data structures.
Also sad that you need all this complexity to test 25 balls in Javascript. 25^2 is a small number in C, especially when your balls fit in cache.
Still a good introduction to various algorithms, though.