Swapping two items in a javascript array - Array.prototype.swap