I need to use these javascript functions inside this file. Said functions are not in a namespace. I dont want to edit that file. How can i import the functions into a namespace in a different file? Preferably without using any third party library.
Say you have header.js
(may be a library) which has
export {
funcA,
funcB,
funcC,
...
}
In another file (may be your file) user.js
(assume it is in the same folder), you can write
import * from "./header.js"
Then in user.js
, you can use funcA
, funcB
, funcC
and any other functions that header.js
exports.
And to avoid name conflict, you can write
import * as header from "./header.js"
Then in user.js
, you can use header.funcA
...
Is this you need?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.