I have a small problem trying to code a snake game in js.
I have this function:
function move() {
var aux = [];
aux = snake.position[snake.position.length - 1];
console.log(aux);
if (snake.direction == 'r') {
snake.position[snake.position.length - 1][1] += 1;
};
console.log(aux);
//updateSnake();
snake.position[snake.position.length - 2] = aux;
updatePosition(snake.position);
};
The problem is that aux is changing itself without me doing anything to it, as you can see. The value from the first console.log is different from the second one! It's not like I'm changing its prototype.
Can you guys help me?