3 ms·
Take a look at this[0] with regards to strings. I'm not really sure why you'd use new String anyway - it won't always act as a string primitive. Rather than ma
by thomasfoster96 11y ago
Take a look at this[0] with regards to strings.
I'm not really sure why you'd use new String anyway - it won't always act as a string primitive. Rather than making Symbol reimplement the same quirks that other built in constructors do, isn't not allowing a Symbol constructor going to avoid a lot of confusion?
For example, if you created an object using a hypothetical symbol constructor, the symbol would be converted to a string if you tried to use it as an object key (internally, JavaScript sees your symbol object as an object, not a symbol), which is simply creating problems for a naive programmer.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FString#Distinction_between_string_primitives_and_String_objects https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- draw_down 11y agoThe point under debate is whether it's inconsistent with Number, String, and Boolean, which it is. I agree `new String` is not particularly useful.
- thomasfoster96 11y agoSorry, I think I misunderstood your point. I thought you meant that inconsistency was worse than misusing constructors.