//代码如下
function doSomeThing(obj){ var adapter = { name:'name', id:'001', color:'yellow', height:'100', '100' }; for(var i in adapter){ adapter[i] = obj[i] || adapter[i]; } console.log(adapter); } var obj = {color:'red'} doSomeThing(obj)
通过适配器的方式,只要通过适配的参数即可作为函数对应的参数,无需按照顺序书写。