This way `listeners[type]`’s length is only calculated once by JavaScript at the beginning of the loop, and not every time the loop’s condition is checked.