This question has already been answered:
It is necessary to replace one variable with another one and change the second one. Like this:
a = b; b = c; The problem is as follows. It is necessary to change the values of variables in the array. Assume inventory[3]['color'] = 'black', inventory[4]['color'] = 'red' .
inventory[3] = inventory[4]; inventory[4]['color'] = 'green'; Then at the end I get inventory[3]['color'] == 'green' Explain why my method does not work, please
[inventory[3], inventory[4]] = [inventory[4], inventory[3]];Although, this method will not work if, apart fromcolor, there are other properties and they do not need to be affected - Deonis