⊗jsSpMdED 212 of 294 menu

Export by default in JavaScript

Only one value can be exported from an ES module. This is done with the export default command. When exporting using this command, it is the imported value that will get into the variable when importing a module.

Let's look at examples. We export one function:

export default function() { return 'text'; };

Let's do the import:

import test from './test.js';

We check the function:

let res = test(); console.log(res);

Create a module that exports a single function.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline