Your error comes from the fact that you are assigning stage1 to the variable fase before the variable stage1 has been initialized.
The computer reads your program from top to bottom but in JavaScript it doesn’t give you an error. You can refer to this previous thread on the subject :
This is what happens :
The JavaScript engine parse your code. Because of hoisting, it moves the declaration of the stage1 variable so it’s doing :
var stage1; // Uninitialized -> undefined
Then we declare and assign stage1 to fase which is undefined:
var fase = stage1; // -> undefined
The stage1 variable gets initialized with the array :