Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda