function connect({host, port, ...user}){ console.log(host);//127.0.0.1 console.log(port);//3306 console.log(user);//Object password: "root" type: "master" username: "root" } connect({ host:'127.0.0.1', port:3306, username:'root', password:'root', type:'master' }) // 扩展运算符 const skillOne = { c: '暗影冲刺' } const skillTwo = { h: '威吓' } const skillThree = { t: '巨力重击' } const skillFour = { e: '幽冥一击' } const spiritBreaker = {...skillOne,...skillTwo,...skillThree,...skillFour}; console.log(spiritBreaker);//{c: '暗影冲刺', h: '威吓', t: '巨力重击', e: '幽冥一击'}