Destructuring is an actively used design pattern. A shorthand assignment method to extract fields from a composite structure.

?Years Old
  • Have a question about Destructuring not answered here? Email me and let me know how I can help.
  • Read more about Destructuring

Languages with Destructuring include coconut, javascript, reason

Example from coconut:

{"list": [0] + rest} = {"list": [0, 1, 2, 3]}

Example from javascript:

const o = {p: 42, q: true};
const {p, q} = o;

Example from reason:

type person = {name: string, age: int};
let somePerson = {name: "Guy", age: 30};
let {name, age} = somePerson;

Last updated August 9th, 2020

Edit Destructuring on GitHub