Skip to main content

divide()

divide(dividend, divisor): number

Divides two numbers.

DEPRECATED

Use the / operator directly instead.


Parametersโ€‹

dividend: numberโ€‹

The first number in a division.

divisor: numberโ€‹

The second number in a division.


Returns: numberโ€‹

The quotient.


See Alsoโ€‹

Division (/) - MDN


Sinceโ€‹

2.0.0


Also known asโ€‹

divide (Lodash, Ramda) ยท โŒ (es-toolkit, Remeda, Radashi, Effect, Modern Dash, Antfu)


Exampleโ€‹

// โŒ Deprecated approach
divide(6, 4); // => 1.5

// โœ… Recommended approach
6 / 4; // => 1.5

How it works?โ€‹

Divides two numbers. Deprecated: Use the / operator directly.

Native Equivalentโ€‹

// โŒ divide(6, 4)
// โœ… 6 / 4

Use Casesโ€‹

Divide numbers ๐Ÿ“Œโ€‹

Divide two numbers.

a / b;

Calculate ratioโ€‹

Calculate proportions.

const ratio = part / total;
const percentage = (count / total) * 100;