Use a consistent null/undefined policy and make it explicit in both type checks and call/return behavior.
Array.isArray) and return a consistent “not found” value (commonly undefined).
const head = arr => (Array.isArray(arr) && arr.length ? arr[0] : undefined);
null in type logic: typeof null === 'object', so include a direct value === null (and don’t assume instanceof covers null).
const isPrimitive = value =>
!['object', 'function'].includes(typeof value) || value === null;
null sentinels in callback calls when semantics matter: if a callback’s behavior depends on arguments, prefer no arguments (or undefined) rather than passing null.
const next = () => {
const fn = fns[curr++];
fn(fn === last ? undefined : next); // or fn() when you want 0 args
};
=== undefined conditionals:
const take = (arr, n = 1) => arr.slice(0, n);
Apply this consistently across helpers to prevent unexpected undefined results, null reference errors, and subtle argument-count differences.