0

I was reading the source for a MeteorJS package (this one) when I came across this:

const {
  getMeteorData,
  pure = true,
} = expandedOptions;

I did some research to figure out what this code would do, but couldn't find any other instance of const being used like this, or any documentation to clarify it for me.

Any hints, please?

Daniel Bastos
  • 143
  • 2
  • 10

1 Answers1

1

It is using es6 to unpack (or destructure) the values inside the expandedOptions object.

const val = {a:1, b:"hello"};
const {
    a,
    b
} = val;

console.log(a); //1
console.log(b); //"hello"
gnicholas
  • 2,041
  • 1
  • 21
  • 32