Skip to content

Instantly share code, notes, and snippets.

@zakirkun
Created June 12, 2022 22:16
Show Gist options
  • Save zakirkun/9ce88d8e4aa07ff695e881f9a0c10302 to your computer and use it in GitHub Desktop.
Save zakirkun/9ce88d8e4aa07ff695e881f9a0c10302 to your computer and use it in GitHub Desktop.
If You Know, You Know
const identity = x => x
const applyFNFroomOptionalParam = x => fn => (fn || identity)(x)
const add2 = a => a + 2
const ifYouKnow = applyFNFroomOptionalParam(3)
const youKnow = applyFNFroomOptionalParam(3)
console.log({
ifYouKnow: ifYouKnow(),
youKnow: youKnow(add2)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment