Home > database >  How does bad importing works in javascript
How does bad importing works in javascript

Time:12-26

I have 3 Vue files, each with a script section. When I am importing the chance js library correctly, all the 3 scripts print a defined object for console.log(chance).

But when I do a bad import,

import {chance} from 'chance'; //<=this is not correct, but works for other files

instead of

import {Chance} from 'chance'; //<=this is the correct one

the first script prints undefined, and after, the second and the third script prints the same object printed previously. Does anyone know how this works?

CodePudding user response:

Reading some documentation with export and import may provide some answers.
For the rest, take the time to learn how JS works in this section.


In the end, there is no general answer to that question. It depends on how the library is written.

  • Related