Skip to content

subtract ​

The subtract() method subtracts one number from another. It supports two forms: a curried form for functional composition and a direct form for immediate calculation.

Interactive example ​

Syntax ​

Classic signature ​

typescript
function subtract<
	GenericInput extends number
>(
	input: GenericInput,
	subtrahend: number
): number

Curried signature ​

typescript
function subtract<
	GenericInput extends number
>(
	subtrahend: number
): (input: GenericInput) => number

Parameters ​

  • input: The number from which to subtract (classic signature only).
  • subtrahend: The number to subtract.

Return value ​

Classic signature: returns the result of the subtraction (value - subtrahend).

See also ​

  • add - Adds two numbers
  • negate - Inverts the sign of a number
  • abs - Returns the absolute value of a number

Sources ​

Released under the MIT license.