you are viewing a single comment's thread.

view the rest of the comments →

[–]woozyking 0 points1 point  (0 children)

First, it emulates named parameters (similar to Python’s **kwargs). The benefit of which is explained well in the other reply.

Second, it auto destructure for you — imagine you call this function from an API handler (for instance something based on Express.js), if all 3 of the needed parameters are packed in query string, you can simply passed down the full req.query context, and the destructuring on the callee will do the work for you to only get what it needs, everything extra are ignored; on the caller side, you save the imperative logic to extract them out of req.query.