The JS API is total crap. One has to use it to develop anything that gets a bit more complex, but MS chose to ignore things that exists in the ES standard (like normal iterators, wtf) for quite some time to preserve backwards-compatibility with IE.
This make neither debugging nor any further exposure to the API any fun.