This repository was archived by the owner on Oct 4, 2020. It is now read-only.
This repository was archived by the owner on Oct 4, 2020. It is now read-only.
Do we want to use the javascript .keys() method? #48
Open
Description
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?
Activity
michaelficarra commentedon Sep 21, 2015
Right now, it appears the library was written with deliberate ES3 support (for instance, using
exports["new"]
instead ofexports.new
), soObject.keys
would be a no-go. I'm also not sureObject.keys
would be faster thanfor-in
, so you should use jsperf to test it.