Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Importing From Export Default Module

/*test.js*/
let x = "XXXXXX"
export default x;

/*index.ejs*/

import Y from '/javascripts/test.js'
window.onload = function(){
console.log(Y);

}

/*With export default we have no restrictions in the name we import the variable as. We also leave out the {}*/
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #Importing #From #Export #Default #Module
ADD COMMENT
Topic
Name
2+9 =