Here's an example of an higher order function called functionA that has customValue as input and returns a function that gets an input and uses the custom value to elaborate a result:
let functionA = (customValue) => {
let value = customValue || 1;
return input => input * value;
};
Here's some results:
functionA()(4)
// => returns 4
functionA(2)(4)
// => returns 8
functionA(3)(4)
// => returns 12
functionA(4)(4)
// => returns 16
Can the function returned by functionA be considered pure?
UPDATE: the examples above are only using numeric input. As described by @CRice, the returned function can be considered pure only when customValue is constant and doesn't have internal state (like classes).
number
(or BigInt, now) – see CRice’s answer – then yes, it’s pure. – Ry-