title: How to negate all elements in javascript array
body: <p>What is the shortest way to negate all elements in a javascript array, with reasonable efficiency?</p>
  
  <p>For example, the solution would convert <code>[0, 18, -1, -2, 1, 3]</code> to <code>[0, -18, 1, 2, -1, -3]</code></p>
  
  <p>The solution does not need to handle any values that are NaN/undefined/null, because the array I need this for does not contain any of those values.</p>
  
  <p>Here is what I normally do (with array <code>array</code>):</p>
  
  <pre><code>for(var i = 0; i &lt; array.length; i++) {
    array[i]*=-1
  }
  </code></pre>
  
  <p>The problem is that I need to invert this array in several places, so don't want to reuse large code.</p>
  
  <p>Thanks</p>