I don't understand why Arr.keys is deprecated when it was actually pretty useful at this place...
(4 lines instead of 1, no try-catch guard). Also the deprecation comment says: Use Object.keys()...

Honza