Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

105
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda