-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
primitive wrapper objects cause unexpected behavior #140
Comments
@vadekh My brain kept drifting back to this issue, and I finally realized why. I remembered that previously I had read that it's a great idea to use primitive object constructors like https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/String Let's update our codebase so that we use |
javascript/src/models/Language.js
Line 107 in 12f0a50
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 yieldobject
rather thanstring
.Fix
The above code should either be converted back to the primitive value
this.#abbreviation = (new String(val)).valueOf()
, or just removedthis.#abbreviation = val;
. Probably the latter.Reference
The text was updated successfully, but these errors were encountered: