Instead of switch to object literal I suggest the facade pattern. Going with facade pattern, your IDE will be able to resolve function definition. If this object resolution grows in complexity it will be harder to understand why this generic function refers to and only your debugger can help you.
The details of this would be an interesting topic for a follow-up article.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.