Answer the question
In order to leave comments, you need to log in
How does declaring variables like "const { x, y } = function()" work?
I found here such declaration of variables
const { check, validationResult } = require('express-validator/check');
var x = something
Answer the question
In order to leave comments, you need to log in
It differs in that more than one variable is returned, an object with named fields that expand into variables. It works something like this:
const {a, b} = {a:'foo', b:'bar'}
console.log(a) // -> foo
console.log(b) // -> bar
This is destructuring. This is the same as
var obj = {a: 10, b: 15};
var a = obj.a;
var b = obj.b
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question