1

I've spent about 20 minutes trying to find more information on the keys function in javascript...

I initially found the keys() function referenced in this answer:

Length of a JavaScript object

hash = {"a" : "b", "c": "d"};
keys(hash); // ["a", "c"]

Does anyone have any more information on this function, especially browser support?

Community
  • 1
  • 1
chim
  • 8,407
  • 3
  • 52
  • 60
  • You are probably looking for this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys – Jonathan Sep 03 '15 at 11:22
  • That's not what I'm looking for Jonathan, Im looking for the documentation for the keys() function not the Object.keys() method or the Array.keys() method. – chim Sep 03 '15 at 13:08
  • Well, look no further. There is no such function in JavaScript. – Jonathan Sep 03 '15 at 16:21
  • lol :) thanks Jonathon – chim Sep 03 '15 at 16:22

1 Answers1

2

There's no such function, it's part of the console api

Description for chrome console: https://developer.chrome.com/devtools/docs/commandline-api#keysobject

For Firefox: https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Helpers

Andrey
  • 4,020
  • 21
  • 35
  • Yep, I've since tried this in a script and it throws Uncaught ReferenceError: keys is not defined – chim Sep 03 '15 at 10:18
  • @Andrey, please don't answer documentation requests like these. Questions like this should be closed as off-topic. – Cerbrus Sep 03 '15 at 10:56
  • This is not a documentation request. This isn't a JavaScript function and that's why there isn't any documentation. So it's a valid question and the answer is valid, although perhaps the answer could be more explicit, (that would be a bit pedantic though). However, I will delete this question if you think that it should be deleted. @Cerbrus – chim Sep 03 '15 at 13:25
  • From your question: _"Where's the documentation?"_ – Cerbrus Sep 03 '15 at 13:41
  • @Cerbrus shoud I delete? Am happy to delete if that's your recommendation. – chim Sep 03 '15 at 13:49
  • As the question currently is, in my _opnion_, yes. However, if you'd edit the question to be more like: _"What is this `keys` function, what does it do?"_, I'd say it has merit. So, focus more on getting an explanation for the function, instead of documentation. – Cerbrus Sep 03 '15 at 13:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/88713/discussion-between-chim-and-cerbrus). – chim Sep 03 '15 at 13:54