0

I just started porting my JS application to modern (modular) JavaScript. I am not very expert in this language, but in Python I normally have a file with many useful variables or costants which are shared (imported) among multiple other scripts within a project.

Is it a good idea to do it in JavaScript as well?

example: i might create a init.js file like:

export const USEFULVAR = "Hello World!";
export const ANOTHERVAR = "What am I doing here???";

and then I can call them in whatever other file like.

whaterverotherfile.js

import * as useful from './init'

useful.USEFULVAR; // "Hello World!"
4

0 回答 0