138
rated 0 times
[
139]
[
1]
/ answers: 1 / hits: 5126
/ 4 Years ago, sun, april 26, 2020, 12:00:00
I have a directory called Polygons
where I have created an index.js
file to export all the files from the directory. It looks something like this:
export {default as europe} from './europe'
export {default as northAmerica} from './northAmerica'
europe
file exports variable like this:
export default europe;
And in the file where I would like to use this variables I am importing them like this:
import * as regions from './Polygons'
I would like to iterate somehow now over those imports, is there any way of doing this?
I have tried doing:
for (const element of regions) {
console.log(element);
}
But, then I get:
Uncaught (in promise) TypeError: Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
More From » es6-modules