Q:

I can alert a variable but javascript console say it is undefined

<html>
<head>
<script type="text/javascript">

var array = new Array(new Array("aa","bb","cc"),new Array("aaa","bbb","ccc"),new Array("aaaa","bbbb","cccc"));

for(var i = 0 ; i <= array.length ; i++) {
    window['dynamic'+i] = array[i];
}

var array2;
var array2val1;
var array2val2;
for(var j=0 ; j<=array.length ; j++) {
    array2 = window['dynamic'+j];
    array2val1 = array2[0];
    array2val2 = array2[1];
    alert(array2val2);
}

</script>
</head>
</html>

I can alert array2val1 and array2val2 but in javascript console they are undefined . What is wrong with them ?
Thanks

A:

for(var i = 0 ; i <= array.length ; i++) {
    window['dynamic'+i] = array[i];
    console.log(window['dynamic'+i])
}

Here in the above iteration, i <= array.length tends to create a undefined  and push it to window['dynamic'+i]
Explanation:
total array length is 3, whereas in iteration you have 
i=0,
i=1,
i=2,
i=3  // no element exists so undefined is pushed to `window['dynamic'+i]`

Same thing here j<=array.length
JSFiddle

