Monthly Archives: May 2021

JavaScript export/import ways

There’s 3 way to do it, all have a difference.

Named Export/Import (example)

//File where are You export some variable
export const name ='some string value';

//File where are You Import
import {name} from "..."

Mandatory :

In Export Module File after word “export” should be name of variable; (without name of variable you will get error, because it’s Named Export – so there should be name!

In Import file after word “import” should be curly braces it´s point out that You want to import exactly that variable name from source ‘…’

‘…’ (three dots) should be the path to file, it’s used just for example, in Your case it will be the path to directory where Your file has been saved for exp. “./Folder/fileName”

Continue reading