js array move to end code example
Example 1: Jquery SEND TO END OF ARRAY
var colors = ['red','blue','green'];
/*// PUSH TO FRONT OF ARRAY
---------------------------*/
colors.push('yellow');
// colors = ['red', 'blue', 'green', 'yellow']
Example 2: javascript move array element to front
for(var i = 0; i<$scope.notes.length;i++){
if($scope.notes[i].is_important){
var imortant_note = $scope.notes.splice(i,1);
$scope.notes.unshift(imortant_note[0]);//push to front
}
}