function create(propertyName) { return function(object1,object2){
var value1 = object1[propertyName];
var value2 = object2[propertyName]; if(value1 < value2) { return -1;
} else { return 0;
}
};
}
1 回答
慕勒3428872
TA贡献1848条经验 获得超6个赞
var compareAge=create('age');
var a1={
age:10
};
var a2={
age:20
};
console.log(compareAge(a1,a2));
添加回答
举报
0/150
提交
取消