function copyProperties(/* object */from, /* optional object */ to){
if (!to) to + {};
for (p in from) to [p] = from[p];
return to;
function copyUndefinedProperties(/* object */ from, /* object */ to){
for (p in from){
if (!p in to) to[p] =from[p];
}
}
看的半懂半不懂的,(/* object */from, /* optional object */ to) 这条是什么意思 /* */ 这符号是什么意思?前面没解释,所以半懂半不懂
说明那个参数是object类型的啊!
if (!to) to + {};
for (p in from) to [p] = from[p];
return to;
function copyUndefinedProperties(/* object */ from, /* object */ to){
for (p in from){
if (!p in to) to[p] =from[p];
}
}
就相当于
function copyProperties(from, to){
if (!to) to + {};
for (p in from) to [p] = from[p];
return to;
function copyUndefinedProperties(from, to){
for (p in from){
if (!p in to) to[p] =from[p];
}
}
个人意见