Skip to content

dist/tinysort.charorder.min.js has a variable use before initialization #174

@krugar

Description

@krugar

The current version of tinysort.charorder.min.js causes the following TypeError (in Firefox 88.0):

Uncaught TypeError: j is undefined (tinysort.charorder.min.js:1:206)

The way I understand this is that Webpack moves the const declaration/initialization of allCharList into a var declaration/initialization below the function definition of prepare, in the assumption that the declaration is hoisted and everything should work. But JavaScript only hoists the declaration of the variable, not the initialization, which means that when allCharList.slice(0) is called, the variable exists, but is not yet initialized, resulting in the "is undefined" error above.

I don't quite know how to tell Webpack to not make this mistake (or whether newer versions of Webpack don't do this), but I'd assume separating declaration and initialization into distinct statements would work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions