Code to go logo
Created using Figma
Use Cases
Contribute
How to destructure with default value in JavaScript
Syntax
By Jad Joubran ·
Last updated Dec 23, 2017
const { id, active = true } = { id: 10, name: "John" }; console.log(id, active);
10 true
Dec 23, 2017
1
Jad Joubran
See answer
1
Jad Joubran
Array destructuring
on MDN
Learn JavaScript step by step
Related use cases
How to destructure from array in JavaScript
How to destructure from object in JavaScript