有沒有var差很大啊,要注意

Output is “7”

$(document).ready(function () {
    x = 6;
});
$(document).ready(function () {
    x = 7;
});
$(document).ready(function () {
    alert(x);
});

x is not defined

$(document).ready(function () {
    var x = 6;
});
$(document).ready(function () {
    var x = 7;
});
$(document).ready(function () {
    alert(x);
});