title: JavaScript move array element to end of array
body: <p><strong>EDIT - 2 elegant solutions</strong></p>
  
  <p>Two elegant solutions, from Pranav and Bekim. Thanks, both tested and worked perfectly.</p>
  
  <p><em>One</em></p>
  
  <pre><code>     for(var x in data)data[x].name == "other" ? data.push( data.splice(x,1)[0] ) : 0;
  </code></pre>
  
  <p><em>Two</em></p>
  
  <pre><code>   var res = data.slice(),
     len = res.length;
  
      for (var i = 0; i &lt; len; i++) {
          if (res[i].name == 'other') {
              res.push(res.splice(i, 1)[0]);
              i--;
              len--;
          }
      }
  </code></pre>
  
  <p><strong>JS TOOLS IM USING</strong></p>
  
  <p>Angular 1.5.6, lodash 4.1x</p>
  
  <p>Here is the scenario I have an array of objects sorted alphabetically e.g. sortedData below etc.. However, within that array is also the catch all <code>Other</code> which is obviously sorted alphabetically as well. I want to remove other from the array and then move to the end of array without messing with the current sorted array. </p>
  
  <p><strong>NOTE</strong></p>
  
  <p>My current approach below works but is ugly. Does JS, angular or lodash have something more elegant? </p>
  
  <pre><code>var data = [
      {id:1,name:'apple'},
      {id:2,name:'banana'},
      {id:3,name:'other'},
      {id:4,name:'tomato'},
      {id:5,name:'strawberry'}
  ];
  
  function move(array, fromIndex, toIndex) {
      array.splice(toIndex, 1, array.splice(fromIndex, 1)[0]);
      return array;
  }
  
  var moved = move(
      data,
      _.findIndex(data, ['name', 'other']),
      Object.keys(data).length
  );
  </code></pre>
  
  <p><strong>Ideal Outcome</strong></p>
  
  <pre><code> var data = [
          {id:1,name:'one'},
          {id:2,name:'two'},
          {id:4,name:'four'},
          {id:5,name:'five'}
          {id:3,name:'other'},
      ]
  </code></pre>