Sign in
Log inSign up

Could anyone tell me the technical difference between these two syntaxes (one wrong) for dynamic imports in Javascript?

Arihant's photo
Arihant
·Oct 2, 2017

First:

let variable = "./components/"
import(`${variable}Home`).then(module => /*works*/)

Second (wrong): Why is this not possible ?

const stringVar = "./components/Home"

import(stringVar).then(module => /* doesn't work */)
Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct