จะให้คำสั่งระบุตัวแปรที่ไม่ได้กำหนดได้อย่างไร? [ทำซ้ำ]

var variable;

function(variable);

function function(variable) {
    alert ("variable equals " + variable);
    if (variable != 'undefined') {
        ~~~code1~~~
    } else {
        ~~~code2~~~
    }
}
var variable;

function(variable)

function function(variable) {
    variable = 2;
    alert ("variable equals " + variable);
    if (exponent == 2) {
        ~~~code1~~~
    } else {
        ~~~code2~~~
    }
}