我有一个功能,就是这个样子 -检查的多个参数中存在一个优雅的方式
var myFunction = function(arg1, arg2, arg3, arg4, arg5, arg6, arg7){
if(typeof arg1 != 'undefined' && typeof arg2 attributeId != 'undefined' && typeof arg3 != 'undefined'){ //and so on for all the arguments
//do something with all of the arguments
}
}
基本上,我检查,如果做某件事之前存在的论据所有7。
这看起来很丑并且不可读。你能提出一个更优雅的方式来实现同样的事情吗?
@JaredPar,你评论的速度比我编辑的要快。 – harpo