Sorry if such question already was. Is there a way to remove item from array and then put it back?
If you want to remove the last element you can use array.pop(). Removing the first element can be done with array.shift(). Removing an item from any position can be achieved with area.splice(startPosition, itemCount). Startposition is the index of the item and itemCount the amount of items you want to grab out of the array.
When the item can be inserted as the last item you can use array.push(element). If it needs to be inserted at any different location, you can use the same array.splice() method. This time with an itemCount of 0, but with a third argument which is the item to insert.
Here is an example:
array = [1, 1, 2, 4, 5]print array# delete one item at index 0array.splice(0, 1)print array# insert number 3 at index 2array.splice(2, 0, 3)print array
Jonas Treub, thank you for your detailed answer!