title: convert javascript spread syntax to older version code
body: <p>I have a piece of code which uses spread syntax.</p>
  
  <p>On my main server, the node js version is 0.10. For some reason, it's not possible to upgrade node js. So I'm converting all the arrow functions such that they are compatible with the old version of node js. I'm not able to convert the spread operator.
  I tried with <code>Object.assign</code> but it keeps showing syntax error. I'm confused on how to convert spread operator to normal javascript code.</p>
  
  <p>Here is my code  : </p>
  
  <pre><code>senddata = Array.from({ ...data, length: Math.max(...Object.keys(data)) });
  </code></pre>
  
  <p>I'm finding it really confusing to convert this. In fact I'm just not able to understand where to add Object.assign and how to fix the syntax errors regarding it.</p>
  
  <p>For arrow function I converted them like this:</p>
  
  <p>with arrow function :</p>
  
  <pre><code>dag.get('obj')
        .then((data) =&gt; {
  
          run();
      }, (err) =&gt; {
          console.log(err)
        })
  </code></pre>
  
  <p>without arrow function</p>
  
  <pre><code>dag.get('obj')
        .then(function(data)  {
  
          run();
      }, function(err) {
          console.log(err)
        })
  </code></pre>
  
  <p>But not able to convert spread syntax.</p>
  
  <p>This is what I tried :</p>
  
  <pre><code>Object.assign({data},length: Math.max(Object.assign({Object},keys(data))
  </code></pre>
  
  <p>Moreover, how can I write the same code without using spread syntax or Object.assign ?</p>
  
  <p>After referring to the answers and suggestions posted below,here is the code :</p>
  
  <pre><code>function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  
  function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i &lt; arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  
  senddata = Array.from({ ...data,
    length: Math.max.apply(Math, _toConsumableArray(Object.keys(data)))
  });
  </code></pre>
  
  <p>But I still get an error for <code>...data</code></p>