JS Standard LibraryPlaygroundPlayground
GitHubGitHub (opens in a new tab)
  • Introduction
    • arrIns
    • arrReplace
    • arrRm
    • bounds
    • chunk
    • compact
    • countBy
    • diff
    • drop
    • groupBy
    • intersection
    • intersperse
    • max
    • min
    • move
    • range
    • reverse
    • shuffle
    • sort
    • sortBy
    • swap
    • symDiff
    • take
    • union
    • uniq
    • isEmpty
    • isEql
    • isEqlArr
    • isNil
    • isShallowEql
    • aCompose
    • aComposeFn
    • aFilter
    • aForEach
    • aMap
    • aPipe
    • aPipeFn
    • aResolvers
    • hexToRGB
    • rgbToHex
    • compose
    • composeFn
    • noop
    • pipe
    • pipeFn
    • sleep
    • avg
    • clamp
    • divMod
    • isDisjointFrom
    • isEven
    • isOdd
    • isSubsetOf
    • isSupersetOf
    • mean
    • median
    • mode
    • percentage
    • percentageOf
    • prod
    • sum
    • isNegZero
    • isZero
    • toNum
    • clone
    • fromPath
    • get
    • has
    • merge
    • mergeAll
    • omit
    • pick
    • set
    • shallowMerge
    • shallowMergeAll
    • size
    • toPath
    • toSet
    • toUnset
    • unset
    • camelCase
    • capitalize
    • insertAt
    • isEmail
    • pascalCase
    • replaceAt
    • strReplace
    • isArr
    • isArrBuf
    • isAsyFn
    • isBigInt
    • isBlob
    • isBool
    • isDataView
    • isDate
    • isDef
    • isErr
    • isFn
    • isGenFn
    • isInfinity
    • isJSON
    • isMap
    • isNull
    • isNum
    • isObj
    • isPureObj
    • isRegEx
    • isSet
    • isStr
    • isSym
    • isTypedArr
    • isUndef
    • isWkMap
    • isWkRef
    • isWkSet

On This Page

  • Syntax
  • Examples
  • Try
Question? Give us feedback → (opens in a new tab)
Maths
prod

Calculates the product of values in the given array.

Syntax

import { prod } from '@opentf/std';
 
prod(
  arr: number[] = [],
  cb?: (val: number, index: number) => number
): number

Examples

prod() //=> 1
 
prod([]) //=> 1
 
prod([1]) //=> 1
 
prod([1, -1]) //=> -1
 
prod([-1, -2]) //=> 2
 
prod([1, 2, 3, 4, 5]) //=> 120
 
const objects = [{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }];
prod(objects, (v) => v.n) //=> 384

Try

percentageOfsum

MIT 2024 © Open Tech Foundation.