Why is it undefined?

by questwork

HTML

<p><b>Question:</b></p>
Why does it alert undefined when I declared the jack variable to be 'Jack'?
<p><b>題目:</b></p>
为什麽提示为"undefined"?

JavaScript

(function() {
    var jack = 'Jack';
})();
alert(typeof jack)