Arity in JavaScript

Arity is the number of arguments or operands that a function or operation in logic, mathematics, and computer science takes.

It means the number of arguments a function takes.

The compose function has two Arity.

const compose = (a, b) => (data) => a(b(data));

The addFive function has one Arity.

const addFive = (num) => num + 5;

In functional programming, although there are no rules of arity, a fewer number of arguments is better.

  1. it makes functions more flexible
  2. it is easy to make compose functions with fewer arguments.

Leave a Reply

Your email address will not be published.

ANOTE.DEV