Lodash unzipWith with Non-Function Iteratee

When using the Lodash _.unzipWith method, passing a non-function argument to the iteratee parameter leads to two distinct outcomes depending on the specific value provided. If the argument is null or undefined, Lodash safely ignores the iteratee and returns the unzipped arrays directly, behaving identically to _.unzip. However, if any other non-function type—such as a string, number, boolean, or plain object—is passed, the execution fails with a runtime TypeError as Lodash attempts to invoke the argument as a function.

Empty Array Short-Circuiting

Before evaluating the iteratee, _.unzipWith checks the input array. If the collection passed as the first argument is null, undefined, or empty ([]), the method immediately returns an empty array []. Under these conditions, the iteratee parameter is never referenced or called, meaning no error will be thrown regardless of what type of value was supplied.

Null and Undefined Values

Lodash explicitly accounts for missing or omitted iteratees. Internally, _.unzipWith checks whether the iteratee is loosely equal to null (iteratee == null).

Because loose equality checks match both null and undefined, passing either value—or omitting the parameter entirely—bypasses function invocation. Instead, Lodash simply returns the result of the standard _.unzip regrouping operation without transforming the elements.

Primitives and Objects Cause a TypeError

Unlike collection methods such as _.map or _.filter, _.unzipWith does not wrap its callback argument in _.baseIteratee. Consequently, it does not support Lodash iteratee shorthands, such as passing a property name string or a matching criteria object.

Once the arrays are regrouped, Lodash passes each grouped set of values to an internal helper that executes the iteratee using standard JavaScript function execution:

iteratee.apply(undefined, group);
// or iteratee.call(undefined, group[0], group[1], ...);

When the iteratee is a primitive (such as 42, 'name', or true) or a non-callable object (such as {}), the .call or .apply property does not resolve to a callable method. JavaScript will immediately throw an unhandled exception:

TypeError: func.apply is not a function

(or TypeError: func.call is not a function, depending on the length of the regrouped array chunk)

Summary of Behavior