Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
i'm completely new to JavaScript and i'm really confused about importing modules

now i saw this code in a video and I don’t know why when I remove the "." an error shows up, so what does it mean?

     import backpack from "./backpack.js";
    
    const markup = (backpack) => {
      return `
      <div>
        <h3>${backpack.name}</h3>
        <ul>
          <li>Volume: ${backpack.volume}</li>
          <li>Color: ${backpack.color}</li>
          <li>Number of pockets: ${backpack.pocketNum}</li>
          <li>Strap lengths: L: ${backpack.strapLength.left}, R: ${
        backpack.strapLength.right
      } </li>
          <li>Top lid: ${backpack.lidOpen ? "Open" : "Closed"}</li>
        </ul>
      </div>
    `;
    };
    
    const main = document.createElement("main");
    main.innerHTML = markup(backpack);
    document.body.appendChild(main);
    export default backpack;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

import backpack from "./backpack.js";

The code shown above is doing a relative import to a file by following the path your provide it. Beginning the path with ./ says "Start in the same folder as this file".

This is different to doing import backpack from "backpack" which doesn't use a file path and instead is looking for a module available in the browser. Therefore the JS runtime will search through the available modules and find the appropriate one, in this case backpack.

If you want a lot more information you can see MDN, though it might be too much information too fast. Good luck!

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

Hope this helps :)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!