Reputation: 143
for example:
greetings = ['hey','hi','hello']
Object.keys(greetings) // ["0", "1", "2"]
BUT
keys(greetings) // [0, 1, 2]
Upvotes: 3
Views: 785
Reputation: 8718
You are trying the command line API's keys, which isn't actually part of standard JavaScript. It's something Chromium-based browsers inject in DevTools.
As for why it returns different results, not sure. On the other hand, in JavaScript, indexing with a number is identical to indexing with the string version of that number, so it doesn't really matter.
Upvotes: 1