JavaScript with Firebug console

Use for testing javascript

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
See console

JavaScript

var data = ["apple", "ball", "cat", "dog", "elephant", "fish", "gorilla"]
var index = [2, 3] // ball and dog
var to = 5 // fish

var arrTemp = [];

data.forEach(function(val,key){

  if(index.indexOf(key)!=-1){

    data.splice((to+1),0,data[key]);
    to++;
    delete data[key];

  }
})
data = data.filter(function(val){ return val != undefined }); 

console.log(data)