-
Notifications
You must be signed in to change notification settings - Fork 624
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
Proposal: is.primitive() to test for boolean, number, or string #294
Comments
Hi @bbusschots-mu! Would |
@jdalton an interesting idea, but I did a little testing and it is subtly different:
As you can see, everything went as expected until I tried with |
|
@jdalton I guess you can argue it's a primitive, but it is definitely an object, so should |
I know this is going to read odd but Object.defineProperty(null, 'a', {value:1 })
// throws Uncaught TypeError: Object.defineProperty called on non-object |
@jdalton odd indeed — but I see your point. I guess it comes down purely to supporting a more human-friendly coding style in two particular ways: Most obviously, I think this the intent of But less obviously, needing to rely on the |
@jdalton are you running this project now? I'd be interested in writing some more features like this, I'd quit before since the creator didn't seem to want to work on it. |
Hi,
I regularly need to check whether or not something is a primitive type, i.e. a boolean, number, or string. ATM I have to write ugly code like:
It would be great to be able to replace that with:
Assuming it would be accepted, I would be happy to write the code for this and submit a pull request. Would such a request get accepted?
The text was updated successfully, but these errors were encountered: