destructuring

JavaScript syntax that unpacks values from an object or array into separate named variables in one step.

In more detail

const { title, count } = props takes two properties out of props, and const [count, setCount] = useState(0) takes the two items of the returned array. Components usually destructure their props right in the parameter list, which is also where defaults are set.

Related terms

Taught in

References