You-Dont-Know-JS icon indicating copy to clipboard operation
You-Dont-Know-JS copied to clipboard

Add: note about type names

Open elkebirmed opened this issue 9 years ago • 5 comments

I think this will help JS developers from getting false when they're expecting true

elkebirmed avatar Dec 14 '15 11:12 elkebirmed

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.

getify avatar Dec 14 '15 13:12 getify

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.

elkebirmed avatar Dec 14 '15 14:12 elkebirmed

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.

getify avatar Dec 14 '15 16:12 getify

Does this help!

elkebirmed avatar Dec 14 '15 17:12 elkebirmed

Thanks.

getify avatar Dec 14 '15 19:12 getify