It's a little different from Object.keys and so on. You can do Object.keys(arr) too, but then you'll get an array of string keys, rather than an iterator of number keys. Interestingly, there's no such thing as Object#keys — I guess it doesn't make sense to return an iterator of keys for something that itself isn't iterable.
Right, because they're class methods on Object that take a param, that's probably why I didn't think to look into how it could work with arrays. Very interesting.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's a little different from
Object.keys
and so on. You can doObject.keys(arr)
too, but then you'll get an array of string keys, rather than an iterator of number keys. Interestingly, there's no such thing asObject#keys
— I guess it doesn't make sense to return an iterator of keys for something that itself isn't iterable.Right, because they're class methods on Object that take a param, that's probably why I didn't think to look into how it could work with arrays. Very interesting.