【发布时间】:2012-01-26 16:40:02
【问题描述】:
我有一个这样的功能 -
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 个参数是否都存在。
这看起来很难看,不可读。你能提出一种更优雅的方式来实现同样的目标吗?
【问题讨论】:
标签: javascript function methods