In ES5 lots of Object utilities are defined on the constructor, not the prototype (e.g. defineProperty
and keys
). What are the reasons behind this design choice? To me, myObject.keys()
seems like a much better API than Object.keys(myObject)
Asked
Active
Viewed 60 times
4

wheresrhys
- 22,558
- 19
- 94
- 162
-
To know the actual reasons, you would have had to have been involved in the discussion about this new feature when it was being designed. I doubt you're going to find that actual information here. – jfriend00 Apr 17 '14 at 09:01
-
1http://stackoverflow.com/questions/11922619/javascript-why-object-keyssomeobject-rather-than-someobject-keys and http://stackoverflow.com/questions/19941499/why-is-object-keys-not-object-prototype-keys – Oleg Apr 17 '14 at 09:04