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.
            Asked
            
        
        
            Active
            
        
            Viewed 46 times
        
    0
            
            
        - 
                    check this https://stackoverflow.com/questions/34338411/how-to-import-jquery-using-es6-syntax – Pranoy Sarkar Dec 08 '19 at 07:47
- 
                    *these javascript functions* - which ones? – Jaromanda X Dec 08 '19 at 08:31
- 
                    @Jaromanda X: All the functions in the file. – O. Altun Dec 08 '19 at 09:17
- 
                    which file? you mean any arbitrary library? you can't change how a library works without changing the library – Jaromanda X Dec 08 '19 at 13:12
1 Answers
0
            
            
        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?
 
    
    
        Wenbo
        
- 1,212
- 8
- 17
