Answer the question
In order to leave comments, you need to log in
How to use object of one file in another?
There is a methods.js file that contains an object
const OBJECT = {
mainFunction: () => {
retrun 'blablabla';
}
};
let a = OBJECT.mainFunction;
import 'methods'
or import OBJECT from 'methods'
and export before const added, the app.js file does not see OBJECT.
Answer the question
In order to leave comments, you need to log in
Or
//
const { OBJECT } = require("./methods");
//
module.exports = {
OBJECT: {
mainFunction: () => {
return "blablabla";
}
}
};
//
import { OBJECT } from "./methods";
//
export const OBJECT = {
mainFunction: () => {
return "blablabla";
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question