Destructuring in iterators
The destructuring feature can be used in a for loop when iterating through an array of objects. In the following example, we have an array of books, each with a title and author name. We use a for loop to list only the book titles. In Line 10, we use the destructuring feature to only pick the property title. this case, variable c gets the value undefined. thrown in this case. This is called fail-soft.
To avoid a fail-soft situation where the JavaScript engine assigns the value undefined, we can also provide variable c with a default value:
There is no error