js的重载

1.重载

//重载(个数不同,类型不同)
function prop(){
var firstP = document.getElementById("p");
if(arguments.length == 1){
var temp = arguments[0];
for(p in temp){
firstP.style[p] = temp[p];
}
}else if(arguments,length == 2){
firstP.style[arguments[0]] = arguments[1];
}
}
prop({
"backgroundColor" : "red";
"fontsize" : "38px";
});

原文地址:https://www.cnblogs.com/goldlong/p/7904083.html