如何检查函数的未定义参数?(在JavaScript中)

ieg*_*gik -4 javascript arguments function undefined

有一些例子:

a = ''; //string
b = 0; //number 0
b1 = 0xf; //number 15
c = (function(){}) //function function (){}
d = []; //object
e = {}; //object [object Object]
f = void(0); //undefined undefined
Run Code Online (Sandbox Code Playgroud)

但是当我尝试传递未定义的变量trougth函数时:

typeof qwerty; //undefined
function at(a){return (typeof a)+' '+a;}
at(qwerty); // ????
Run Code Online (Sandbox Code Playgroud)

..i`v收到错误"Uncaught ReferenceError:qwerty未定义".我怎样才能(是否存在最短路径)创建函数isDefined(a,b)或减少该表达式的其他技巧?:

c=(typeof a!='undefined'&&a||b)
Run Code Online (Sandbox Code Playgroud)

澄清:如果a被定义--c等于a,overwise -b,就像php中的"c = @ a?:b"

编辑:

function ud(_a){return typeof window[_a]==='undefined'}

a=undefined; b=3;
alert((ud('a')?4:a)+(ud('b')?5:b));?
Run Code Online (Sandbox Code Playgroud)

Ale*_* K. 5

function isDefined(variable, dflt) {
    return typeof variable === "undefined" ? dflt : variable;
}

var c = isDefined(a, b);
Run Code Online (Sandbox Code Playgroud)