Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Do we want to use the javascript .keys() method? #48

Open
jbrownson opened this issue Sep 21, 2015 · 1 comment
Open

Do we want to use the javascript .keys() method? #48

jbrownson opened this issue Sep 21, 2015 · 1 comment

Comments

@jbrownson
Copy link

There are several places we iterate over keys, and we're using the for/in method with hasOwnProperty. This is correct, but might it be better to use the .keys() method (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)?

It would remove the need for the hasOwnProperty check so it seems like it could only be faster, but it would have less browser support. I'm not sure what browsers we try to support?

Or maybe if it ain't broke don't fix it?

@michaelficarra
Copy link

Right now, it appears the library was written with deliberate ES3 support (for instance, using exports["new"] instead of exports.new), so Object.keys would be a no-go. I'm also not sure Object.keys would be faster than for-in, so you should use jsperf to test it.

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

No branches or pull requests

2 participants