We’ve also got an implementation of a self-balancing binary tree in JavaScript. You can grab it from our GitHub at https://github.com/PachiSystems/JSAVLTree.

By nature, AVLTrees cannot contain duplicates, but have the benefit that all information entered into them is immediately sorted and operations are generally fast. If you’re going to use this with objects, you’ll have to specify your own sort method when you instantiate your AVLTree.