Skip to content

Should the ES Modules Example Use a Capitalized Constructor Function for Classic-Style Multiple Instantiation? #1920

@RED523

Description

@RED523

Edition: 2nd

Book Title: 《You Don't Know JS Yet: Get Started - 2nd Edition》

Chapter: Chapter 2: Surveying JS

Section Title: ES Modules

Question:
To avoid ambiguity, use classic modules to support the multiple-instantiation scenario within ES Modules. Shouldn't the example in the documentation be consistent with the "Classic Modules" section above? Specifically:

  1. The function name should start with a capital letter.
  2. The function returns an "instance" of the module and exposes one or more functions that can operate on the module instance's internal (hidden) data.

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