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

type checking and isWhat #6

Open
sparcut opened this issue Nov 11, 2017 · 2 comments
Open

type checking and isWhat #6

sparcut opened this issue Nov 11, 2017 · 2 comments

Comments

@sparcut
Copy link

sparcut commented Nov 11, 2017

I'm interested in your methods of type checking and wondering why you use it over typeof.

https://github.com/ecmadao/chrome-utils/blob/master/src/utils/helper.js

I'd have to assume it's either performance or for getting type of array?

@ecmadao
Copy link
Owner

ecmadao commented Nov 12, 2017

Because typeof can not check Array type. Actually, you can also use Array.isArray to check if is array, or use array.constructor === Array. For browser compatibility reason, I'm using Object.prototype.toString.call(It can also changed to x.constructor === Array/Number/Object)

@sparcut
Copy link
Author

sparcut commented Nov 16, 2017

Ohh I see.

But hol up ☝️, whats the point of browser compatibility if you know its only gonna be used in chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants