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;