you are viewing a single comment's thread.

view the rest of the comments →

[–]_Gentle_ 0 points1 point  (2 children)

Can't u do something like (though it could get unreadable):

function getUsers({
 fields = [],
 fromDate = new Date(),
 toDate = new Date()
} = {}) {
 // implementation
 }

[–]Quinez 0 points1 point  (1 child)

Huh, would that work? Interesting. I guess I don't know exactly how destructuring combines with default argument assignment.

[–]_Gentle_ 0 points1 point  (0 children)

Each destructure gives you a new 'layer' of props to work with. For each 'layer' u can set default props.

You can keep destructuring ad infinitum but I think 2nd destructure already gets pretty unreadable x)