3
我試圖將一個子對象拷貝到一個變量中,但似乎只是簡單地聲明它,只有拷貝的關鍵字被拷貝了。我如何複製整個對象?這裏就是我想...在JavaScript中拷貝一個子對象
const baseObj = {
players: {
player1: {
name: "hello",
details: "something"
},
player2: ...
}
}
const player1Copy = baseObj.players.player1
// I want to grab out the whole object player1 instead of just the key
替代現代JS'讓克隆= {... baseObj。 players.player1}; ' –