My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

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 */)