# 10 examples of 'function multiply(a b) a * b' in JavaScript

Every line of 'function multiply(a b) a * b' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

## All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
``26export function multiply<N extends number>(27  a: Vector<N>,28  b: Vector<N> | number29): Vector<N> | number {30  return math.multiply(a, b) as Vector<N> | number;31}``
``42export function multiply(a, b) {43  const a00 = a[0], a01 = a[1], a02 = a[2];44  const a10 = a[3], a11 = a[4], a12 = a[5];45  const a20 = a[6], a21 = a[7], a22 = a[8];4647  const b00 = b[0], b01 = b[1], b02 = b[2];48  const b10 = b[3], b11 = b[4], b12 = b[5];49  const b20 = b[6], b21 = b[7], b22 = b[8];5051  a[0] = b00 * a00 + b01 * a10 + b02 * a20;52  a[1] = b00 * a01 + b01 * a11 + b02 * a21;53  a[2] = b00 * a02 + b01 * a12 + b02 * a22;5455  a[3] = b10 * a00 + b11 * a10 + b12 * a20;56  a[4] = b10 * a01 + b11 * a11 + b12 * a21;57  a[5] = b10 * a02 + b11 * a12 + b12 * a22;5859  a[6] = b20 * a00 + b21 * a10 + b22 * a20;60  a[7] = b20 * a01 + b21 * a11 + b22 * a21;61  a[8] = b20 * a02 + b21 * a12 + b22 * a22;6263  return a;64}``
``3function multiply(a, b) {4  return a * b;5}``
``12function multiply (a: [ number, number ], b: [ number, number ]): [ number, number ] {13    return [ ((a[0] * b[0]) - (a[1] * b[1])), ((a[0] * b[1]) + (a[1] * b[0])) ];14}``
``41export function multiply(a, b) {42  return [43    a[0] * b[0] + a[1] * b[3] + a[2] * b[6],44    a[0] * b[1] + a[1] * b[4] + a[2] * b[7],45    a[0] * b[2] + a[1] * b[5] + a[2] * b[8],46    a[3] * b[0] + a[4] * b[3] + a[5] * b[6],47    a[3] * b[1] + a[4] * b[4] + a[5] * b[7],48    a[3] * b[2] + a[4] * b[5] + a[5] * b[8],49    a[6] * b[0] + a[7] * b[3] + a[8] * b[6],50    a[6] * b[1] + a[7] * b[4] + a[8] * b[7],51    a[6] * b[2] + a[7] * b[5] + a[8] * b[8]52  ];53}``
``8export function multiply(9  a: Transformation,10  b: Transformation11): Transformation {12  return Matrix.multiply(a, b);13}``
``9function multiply(a, b) {10  return (a * b) || 0;11}``
``229mul(b:Matrix4):Matrix4 {230    var a:Matrix4 = this;231    var m:Matrix4 = new Matrix4();232    m.x00 = a.x00 * b.x00 + a.x01 * b.x10 + a.x02 * b.x20 + a.x03 * b.x30;233    m.x10 = a.x10 * b.x00 + a.x11 * b.x10 + a.x12 * b.x20 + a.x13 * b.x30;234    m.x20 = a.x20 * b.x00 + a.x21 * b.x10 + a.x22 * b.x20 + a.x23 * b.x30;235    m.x30 = a.x30 * b.x00 + a.x31 * b.x10 + a.x32 * b.x20 + a.x33 * b.x30;236    m.x01 = a.x00 * b.x01 + a.x01 * b.x11 + a.x02 * b.x21 + a.x03 * b.x31;237    m.x11 = a.x10 * b.x01 + a.x11 * b.x11 + a.x12 * b.x21 + a.x13 * b.x31;238    m.x21 = a.x20 * b.x01 + a.x21 * b.x11 + a.x22 * b.x21 + a.x23 * b.x31;239    m.x31 = a.x30 * b.x01 + a.x31 * b.x11 + a.x32 * b.x21 + a.x33 * b.x31;240    m.x02 = a.x00 * b.x02 + a.x01 * b.x12 + a.x02 * b.x22 + a.x03 * b.x32;241    m.x12 = a.x10 * b.x02 + a.x11 * b.x12 + a.x12 * b.x22 + a.x13 * b.x32;242    m.x22 = a.x20 * b.x02 + a.x21 * b.x12 + a.x22 * b.x22 + a.x23 * b.x32;243    m.x32 = a.x30 * b.x02 + a.x31 * b.x12 + a.x32 * b.x22 + a.x33 * b.x32;244    m.x03 = a.x00 * b.x03 + a.x01 * b.x13 + a.x02 * b.x23 + a.x03 * b.x33;245    m.x13 = a.x10 * b.x03 + a.x11 * b.x13 + a.x12 * b.x23 + a.x13 * b.x33;246    m.x23 = a.x20 * b.x03 + a.x21 * b.x13 + a.x22 * b.x23 + a.x23 * b.x33;247    m.x33 = a.x30 * b.x03 + a.x31 * b.x13 + a.x32 * b.x23 + a.x33 * b.x33;248    return m249}``
``44export function multiply (C: Matrix, A: Matrix, B: Matrix) {45  let i = 046  let j = 047  let k = 048  let Ap = 049  let pA = 050  let pB = 051  let _pB = 052  let Cp = 053  const ncols = A.cols54  const nrows = A.rows55  const mcols = B.cols56  const ad = A.data57  const bd = B.data58  const cd = C.data59  let sum = 0.06061  for (; i < nrows; Ap += ncols, i++) {62    for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {63      pB = _pB64      pA = Ap65      sum = 0.066      for (k = 0; k < ncols; pA++, pB += mcols, k++) {67        sum += ad[pA] * bd[pB]68      }69      cd[Cp] = sum70    }71  }72}``
``46function multiply( C, A, B ){47    var i=0,j=0,k=0;48    var Ap=0,pA=0,pB=0,p_B=0,Cp=0;49    var ncols=A.cols,nrows=A.rows,mcols=B.cols;50    var ad=A.data,bd=B.data,cd=C.data;51    var sum=0.0;5253    for (; i < nrows; Ap += ncols, i++) {54        for (p_B = 0, j = 0; j < mcols; Cp++, p_B++, j++) {55            pB = p_B;56            pA = Ap;57            sum = 0.0;58            for (k = 0; k < ncols; pA++, pB += mcols, k++) {59                sum += ad[pA] * bd[pB];60            }61            cd[Cp] = sum;62        }63    }64}``