透過範例了解 Javascript Destructuring (解構指定值)
物件解構 指定值給已存在的變數 const superHero = { name : "Spiderman", power : "Spider Sense", color : "red" }; const { name, power, color } = superHero; console.log("name:", name); // Spiderman console.log("color:", color); // red console.log("power:", power); // Spider Sense 重新指定值的用法 const superMan = { name : "Superman", power : "Super Sense", color : "blue" }; ({ name, power, color } = superMan); console.log("name:", name); console.log("color:", color); console.log("power:", power); 指定值給新的變數 const superHero = { name : "Spiderman", power : "Spider Sense", color : "red" }; const { name : n, power : p, color : c } = superHero; console....