//当我们定一个函数的时候,入参是一个对象的情况下 //{location,restaurant}={} 给这个对象一个默认值 function breakfast(drink,food,{location,restaurant}={}){ console.log(drink,food,location,restaurant); } breakfast('咖啡','面包'); breakfast('咖啡','面包',{location:"杭州",restaurant:'云栖'});