# 10 examples of 'multiplication in javascript' in JavaScript

Every line of 'multiplication in javascript' 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
``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}``
``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}``
``75function multiply (multiplier, ...theArgs) {76  return theArgs.map(function (element) {77    return multiplier * element78  })79}``
``43function testMultiplicativeMulMul() {44	assertEquals(24, evaluateXPathSingle("2 * 3 * 4"));45}``
``3function multiply(a, b) {4  return a * b;5}``
``1091function multiply(out, a, b) {1092    var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],1093        a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],1094        a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],1095        a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];10961097    // Cache only the current line of the second matrix1098    var b0  = b[0], b1 = b[1], b2 = b[2], b3 = b[3];  1099    out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30;1100    out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31;1101    out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32;1102    out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33;11031104    b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7];1105    out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30;1106    out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31;1107    out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32;1108    out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33;11091110    b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11];1111    out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30;1112    out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31;1113    out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32;1114    out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33;11151116    b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15];1117    out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30;1118    out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31;1119    out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32;1120    out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33;1121    return out;1122};``
``3function mult (num) {4  return num + dep4.multiplier;5}``
``26export function multiply(27  a: Vector,28  b: Vector | number29): Vector | number {30  return math.multiply(a, b) as Vector | number;31}``
``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 &lt; nrows; Ap += ncols, i++) {62    for (_pB = 0, j = 0; j &lt; mcols; Cp++, _pB++, j++) {63      pB = _pB64      pA = Ap65      sum = 0.066      for (k = 0; k &lt; ncols; pA++, pB += mcols, k++) {67        sum += ad[pA] * bd[pB]68      }69      cd[Cp] = sum70    }71  }72}``