I have an object like this:
const myObject = { 'docs.count': 1000, uuid: 11244, 'pri.store.size': 2453 }
I would like to do a destructuring assignment. Is that only possible for this type of fields?
const { uuid } = myObject;
Thanks!
I have an object like this:
const myObject = { 'docs.count': 1000, uuid: 11244, 'pri.store.size': 2453 }
I would like to do a destructuring assignment. Is that only possible for this type of fields?
const { uuid } = myObject;
Thanks!
Variable names can't include a dot, so you can't get do const docs.count = 1000
, for example. Destructuring allows you to extract the values even if the property name can't be a the name of a variable, but you'll need to assign them a valid variable name:
const myObject = { 'docs.count': 1000, uuid: 11244, 'pri.store.size': 2453 }
const { 'docs.count': docsCount } = myObject;
console.log(docsCount);