<script> window.onload = function() { this.arr = [0,1,2,3,4,5]; }; </script> .... <script> setTimeout(function() { alert(arr); }, 0); </script>