我想將屬性從對象拉入函數(shù) var:income let obj1 = { x: { income: 200, sex: 'male' }, y: 'name1' }; function informUserData({ //what to put here ? }){ return income; } console.log(informUserData(obj1));// it should be 200我試過這個:function informUserData({ x{ income } }){ return income; } console.log(informUserData(obj1));然后,我嘗試了這個,只是為了檢查如何解壓縮無嵌套屬性值。 let obj1 = { x: { income: 200, sex: 'male' }, y: 'name1' }; function informUserData({ y }){ return y } console.log(informUserData(obj1)); // name1
如何將嵌套數(shù)據(jù)解壓縮到函數(shù)中?
holdtom
2022-09-29 10:46:00
