Identity Closure

Published: 1/18/2020
Last edited: 1/26/2020

Did you intend to write a function alias?

An identity closure refers to a function which calls another function and returns the result, usually doing no intermediary translation.

const shout = x => x.toUpperCase()
const identityClosure = x => shout(x)
const inputs = [
 '(usually)', 'no', 'need',
 'for', 'identity', 'closures'
] === => shout(x)) ===

NB The only valid case for an identity closure is when there is a scope / binding which breaks in the tacit (un-closured) form.

Watch out for this anti-pattern: needless aliases make it harder when tracking a function through a codebase. Be explicit about what your function does by naming it clearly. However, at the same time be careful about explicit function arity, especially when using native

Published: 1/18/2020
Last edited: 1/26/2020
Content by brekk
See this page on Github
Built with 💛 by Open Sorcerers
Created with Gatsby using the 😎 foresight starter