You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module.exports=12// Exporting a single numbermodule.exports=function(){}// exporting a single functionmodule.exports={// exporting an objectkey: value}
imports (require)
constvariable=require("module");// Importing a single thingconst{ key }=require("module");// Importing a thing from the exported object using destructuring
ES Modules
exports
exportconstnum=12;// Exporting a named numberexportfunctionfoo(){}// Exporting a named functionexportconstobj={key: value}// Exporting a named objectexportdefault12// Exporting a default numberexportdefaultfunction(){}// Exporting a default functionexportdefault{// Exporting a default objectkey: value}
imports
importvariablefrom"module.js"// Importing a default exportimport{num}from"module.js"// importing a named exportimportvariable{num}// Doing both at once.import{numasnumber}from"module.js"// Renaming a named import (aliasing)