🔰nested destructuring

JSoperatorassignmentdestructuring ⟩ nested

💾 程式:replit

let opts = {
    size : {width: 100, height: 200},    // object in object
    items: ["Cake", "Donut"],            // array in object
    extra: true
};

// ⭐ nested destructuring
let {
  size : {width, height},
  items: [a, b],
  title = "Menu"                         // default value
} = opts;
// width=100, height=200, a="Cake", b="Donut", title="Menu"

Last updated