Assigning default values while object destructuring
· ☕ 1 min read
Easily assign default values while destructuring objects.
Consider below code-
1 2 3 4 const obj = { x: 9, y: 1 }; const { x, y } = obj; console.log(x, y); // 9 1 A typical destructuring of objects, this code assigns x and y variables to the x/y props of object obj.