⊗jsSpMdIm 209 of 294 menu

ES module import in JavaScript

Let's now include a module in another file. This is done with the commands import and from.

After the import command, names of the imported functions should be written in curly brackets. And after the command from - a path to the imported file.

In our case, we will import the functions root2 and root3:

import {root2, root3} from './math.js';

After such an import, the root2 and root3 functions will be available to us. Let's use them:

let res = root2(2) + root3(3); console.log(res);

Import the module you created in the previous lesson. Test your imported functions.

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