How To Export & Import?

I just wanna import everything to main.js and using it in browser’s console or Node.
I try with everything
import all is posible? i mean, write ‘animales’ in console and display it?


h3
h2

I don’t see where you are trying to import and export. Do you have a link?

array.js to main.js. I want to use main.js in the console of the brower and be capable to use the array in the ‘array.js’

You have to export the array from the array.js first. Then you can import it to main.js.

Yes, I would expect to see the variables animales being declared from array.js with something like:

export const animales = [
// ...

This would replace line 1 of that file. That would make it accessible as a named export. Then as Ricardo explains, you can import it in main.js with something like:

import { animales } from './array';

That would make it accessible to that file.

We’ll discuss your obsession with castrated animals some other time. :wink:

2 Likes