var food = 'banana'; //变量生成对象 var foodObj = {food}; console.log(foodObj);//{food: "banana"} //形式参数生成对象 function getName(name,age){ return {name,age}; } const nameObj = getName('liuq',20); console.log(nameObj); console.log(nameObj.name); console.log(nameObj['age']);