Skip to content
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

What is the logic of check-types lower- or upper-case? #29

Closed
Redsandro opened this issue Mar 4, 2017 · 1 comment
Closed

What is the logic of check-types lower- or upper-case? #29

Redsandro opened this issue Mar 4, 2017 · 1 comment
Labels

Comments

@Redsandro
Copy link
Contributor

check-types ensures that case of native types is the same as in this list:

boolean
number
string
Object
Array
Date
RegExp

There is probably a good reason, but why are boolean, number, string in lower case, but the rest upper case?

I get that you can do new Object(), new Array() etc. but you cannot do new number(), it must be new Number().

I also get that typeof new Array will say object even though we decided that the type is Object. So the typeof function doesn't really give the type, just a lowercase translation of the parent type, which is Object and not object. Shouldn't we treat all cases the same?

(new Array()).constructor.name
"Array"
(new Number()).constructor.name
"Number"
(new Function()).constructor.name
"Function"
(new Boolean()).constructor.name
"Boolean"

I think either string, number and boolean should also be capitalized, or object should be with a lower case because typeof Object() is object.

Am I wrong?

@gajus gajus added the question label Mar 4, 2017
@gajus
Copy link
Owner

gajus commented Mar 4, 2017

#25

@gajus gajus closed this as completed Mar 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants