title: Passing a function as an argument in a javascript function
body: <p>I was wondering whether this is legal to do. Could I have something like:</p>
  
  <pre><code>function funct(a, foo(x)) {
    ...
  }
  </code></pre>
  
  <p>where <code>a</code> is an array and <code>x</code> is an integer argument for another function called <code>foo</code>?</p>
  
  <p>(The idea is to have one function that uses a for loop on the array, and calls that function in the params for every element in the array. The idea is so call this on different functions so elements of two arrays are multiplied and then the sums are added together. For example <code>A[0] * B[0] + A[1] * B[1]</code>.)</p>