Helper Functions

Learn about helper functions and practice the concept through a use case.


A helper function is essentially a function that provides assistance in performing a task.. The definition of a helper function is quite flexible and borderline ambiguous, but one thing remains clear about them. That is, they make programs much easier to read. Helper functions vary in utility from being enforcers of patterns to abstracting away the internals of frequently-used operations.

In theory, any purposeful function with explicitly defined inputs and outputs can exist as a helper function. It is, however, the purity (and, by extension, referential transparency) and a certain universality in application that makes a function a helper function.

Helper functions are documented relative to groupings that best reflect their usefulness in libraries. For instance, the helper functions, map, filter, and fold, typically fall into the list categories because they work best with arrays and similar structures. The compose and partial often feature in a genealogy of higher-order functions whose arguments are functions. This grouping consolidates the guiding principle on the application of helper functions and should be given the necessary attention. The functions described in the following example can be used to transform lists and compose functions. They can be strung together in various combinations as needed.

Use case for helper functions

Shown below is a simple use case for pure helper functions.

Get hands-on with 1200+ tech skills courses.