That's a null reference error. Your event is not defined so accessing its length property by events.length will throw an error.
events.length