I have this code -
var status = ["A", "B", "C", "D", "E", "F"];
$(function() {
console.log(window.status);
console.log(typeof window.status);
var status = ["A", "B", "C", "D", "E", "F"];
console.log(status);
console.log(typeof status);
});
.as-console-wrapper { max-height: 100% !important; top: 0; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Outside of $(function() {}); the var status is declared as an array.
Yet when it comes to logging it to console, it shows up as a String.
I repeat with the same thing inside the ready function and it behaves as it should this time. What's wrong with this code?