Skip to content

Use Object.entries #15

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

Closed
monolithed opened this issue Mar 30, 2017 · 4 comments
Closed

Use Object.entries #15

monolithed opened this issue Mar 30, 2017 · 4 comments

Comments

@monolithed
Copy link

        for (const prop in e) {
            if (hasOwnProperty(e, prop)) {
                result.push(prop);
            }
        }
        for (const [prop, value] of Object.entries(e)) {
                result.push(prop);
        }

I believe the second example looks more elegant

@dphilipson
Copy link
Owner

Hi monolithed,

Unfortunately Object.entries() is not supported in all major browsers. In particular, it is absent from Safari on iOS and from Internet Explorer, according to MDN's page on Object.entries().

Actually though, your mentioning this made me realize that it should be using Object.keys() instead, so I'll make that change when I have the chance. Thank you!

@monolithed
Copy link
Author

I believe people know about polyfils.

@dphilipson
Copy link
Owner

Consumers shouldn't need to install a polyfill to use a 40 line library.

@dphilipson
Copy link
Owner

Alright, should be fixed. The new version simply says

return Object.keys(e) as Array<keyof T>;

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