What it means to declare const {service} in Javascript, NODE.js

Asked

Viewed 28 times

3

When I started studying Node.JS I came across the following code snippet:

Example with services that shows middleware Factory Advantages.

...

const {service} = options;
router.get('/greet', (req, res, next) => {
        res.end(
                service.createGreeting(req.query.name || 'Stranger')
        );
 });
return router;

What does this statement mean, why these {} in the service?

const {service} = options;

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.