Let's imagine that I have two files. File number one is called obj.js
and looks like this:
const obj = {
item1: 'some text',
item2: 'some other text',
item3: 'more text'
...
item99: `yet more text`
}
export default obj
File number 2 looks is called main.js
and looks like this:
import obj from './obj.js'
Now, here is my question. In file number two (main.js
) I can access properties off of the obj Object like this: obj.item2
. What I want to know is can I destructure this object so that I can access any of the properties as follows: item2
, item26
, item38
, etc (i.e., without the need to preface it with obj.
)?
If so, any idea how?
I'm not trying to import any particular property, but rather want the option of using whichever properties I chose to without the need to reference obj
.