Skip to content

primitive wrapper objects cause unexpected behavior #140

@dwhieb

Description

@dwhieb

this.#abbreviation = new String(val);

Describe the bug
Using a primitive wrapper object (new String) here causes unexpected behavior, because unlike normal instantiation of primitives, the wrapper object is not discarded after instantiation. In the code above, typeof this.#abbreviation will yield object rather than string.

Fix
The above code should either be converted back to the primitive value this.#abbreviation = (new String(val)).valueOf(), or just removed this.#abbreviation = val;. Probably the latter.

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions