You-Dont-Know-JS
You-Dont-Know-JS copied to clipboard
Add: note about type names
I think this will help JS developers from getting false when they're expecting true
I think this is inaccurate. String
is an object
, that is boxed (wrapped) around a string
primitive. They're correlated, but not at all the same thing.
That's right but let's see this example:
typeof 'Hello' === 'string' // true
typeof 'Hello' === 'String' // false (this typo will change the world :D)
did you get what i mean, JS developers will think that the type is not a string while it's so.
The note could say "Note: the string values returned from typeof
are all lowercase." That doesn't help that much, but maybe just a slight bit.
But as written, I think the current PR is inaccurate/misleading. If you'd like to update the PR to the above suggested wording, I could consider that for second edition.
Does this help!
Thanks.