I’m pretty sure it cannot be simpler thing to do, hence why I cannot find anything useful about this. Invoking deletion of the element and pushing it so that it becomes last seems too ugly for this.
Five values in an array:
var array = ['cat', 'dog', 'turtle', 'zebra', 'pterodactylus'];
So, I just want dog to get pushed at the end of the array:
var array = ['cat', 'turtle', 'zebra', 'pterodactylus', 'dog'];
Simple as that.
1 Answer