Array[Array.length] doesn't seem to work properly?

Hey everyone. So I’m just doing a few things with arrays at the moment, and I am using this code to add an element from allNodes to checkNodes:

checkNodes[checkNodes.length] = allNodes*;

I run a trace on the array before and after I run this code, and the element is added just fine!

But if I add a trace directly after it like this:

checkNodes[checkNodes.length] = allNodes*;
trace(checkNodes[checkNodes.length]);

I am returned an *undefined. *​

BUT, if I change it to trace a specific element like this:

checkNodes[checkNodes.length] = allNodes*;
trace(checkNodes[0]);

I am returned the correct value! Why exactly would that be?

Thanks in advance for your help!