Ramda.js R.product() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Ramda’s R.product() takes a list of numbers and multiplies them all together. The official docs sample is R.product([2, 4, 6, 8, 100, 1]) → 38400. Added in v0.1.0. See also R.reduce.

Internally Ramda reduces with R.multiply starting from 1. That is why an empty list is 1, a one-item list returns that item, and a single 0 anywhere makes the whole product 0.

Syntax

Call R.product. Start with this line.

Ramda
R.product(list)
CallWhat it does
R.product(list)Primary signature.
R.product(...)Call the math helper.

Prefer import { product } from "ramda" when you want a named import.

Library declarations
Ramda
R.product(list)

Parameters

ParameterDescription
listRequired. an array of numbers. Ramda multiplies every item together.

Return Value

Return ValueDescription
*Returns a Number: the product of all items.

Ramda Examples

📚 Getting Started

The official 38400 sample, then the reduce equivalent.

Example 1 — The Official Docs Example

From ramdajs.com/docs/#product: R.product([2, 4, 6, 8, 100, 1]) returns 38400.

Ramda
R.product([2, 4, 6, 8, 100, 1]);  //=> 38400
R.product([2, 3, 4]);             //=> 24
R.product([10]);                  //=> 10
R.product([]);                    //=> 1
Try It Yourself

How It Works

2 × 4 × 6 × 8 × 100 × 1 is 38400 — the official sample. A one-item list is that item. An empty list leaves the starter value 1.

Example 2 — Same as R.reduce(R.multiply, 1)

The docs point to R.reduce. Product is that fold with a multiply step and starter 1.

Ramda
R.product([2, 3, 4]);
//=> 24

R.reduce(R.multiply, 1, [2, 3, 4]);
//=> 24

R.multiply(2, 3);
//=> 6
Try It Yourself

How It Works

R.product is the named shortcut for reducing a list with multiply. R.multiply(2, 3) is only two numbers — use it when you do not have an array.

📈 Practical Patterns

Zeros vs sum, pluck pipelines, and empty-list identities.

Example 3 — A Zero Wipes the Product

Any 0 in the list makes the product 0. Sum still totals the rest.

Ramda
R.product([2, 0, 5]);   //=> 0
R.sum([2, 0, 5]);       //=> 7
R.product([2, -3, 4]);  //=> -24
Try It Yourself

How It Works

Multiplication by zero is always zero, so one 0 short-circuits the whole product. An odd count of negatives makes the product negative: 2 × -3 × 4 is -24.

Example 4 — Product of an Object Field

Pluck a numeric property, then multiply the resulting list.

Ramda
var boxes = [
  { name: "A", qty: 2 },
  { name: "B", qty: 3 },
  { name: "C", qty: 4 }
];

R.pipe(R.pluck("qty"), R.product)(boxes);
//=> 24
Try It Yourself

How It Works

R.pluck("qty") builds [2, 3, 4]. R.product multiplies that list to 24. Both steps are unary, so they drop into R.pipe with no lambdas.

Example 5 — Empty-List Identities

Product, sum, and mean treat an empty list differently. That is worth memorizing.

Ramda
R.product([]);  //=> 1
R.sum([]);      //=> 0
R.mean([]);     //=> NaN
Try It Yourself

How It Works

Reduce-with-multiply starts at 1, so no items leaves 1. Reduce-with-add starts at 0. R.mean divides by length, so an empty list is 0 / 0 → NaN.

Browser Support

R.product() is plain JavaScript multiplication over a list — it runs anywhere Ramda loads: every modern browser plus Node.js. Logos use the shared browser-image-sprite.png sprite from this project.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.product()

Load Ramda via CDN or npm, then call R.product(list). Because it only multiplies numbers, behavior is identical across engines.

100% With Ramda loaded
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
R.product() Universal

Bottom line: Safe in any project that includes Ramda. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node.

Frequently Asked Questions

R.product(list) multiplies together every number in a list and returns that single product. It is Ramda's unary list-product helper, so you can pass it to R.pipe or R.pluck pipelines without writing a lambda.
R.product([2, 4, 6, 8, 100, 1]) returns 38400. That is the sample on ramdajs.com/docs/#product. Added in v0.1.0. See also R.reduce.
Yes. It has arity 1 and is automatically curried. Call R.product([2, 4, 6]) for a number. Calling R.product() with no argument returns a function that waits for the list.
R.product([]) returns 1 — the multiplicative identity. Internally it is R.reduce(R.multiply, 1, list), and reducing with no items leaves the starter value 1. Contrast with R.sum([]) which is 0, and R.mean([]) which is NaN.
R.multiply(a, b) takes two numbers. R.product(list) multiplies every item in an array. R.product([2, 3, 4]) is the same as R.reduce(R.multiply, 1, [2, 3, 4]).
No. R.product is a stable Ramda math helper from v0.1.0. It is not deprecated, experimental, or non-standard.

Continue to R.mean()

Learn list averages after you know how to multiply every number.

R.mean() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful