0

Things like Math and JSON are somehow objects with keys, but they report as having no keys.

> Object.keys(JSON);
Array(0) []

> [...JSON]
TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))

> Object.getOwnPropertySymbols(JSON);
Array(1) [Symbol(Symbol.toStringTag)]
  length:1
  __proto__:Array(0) [, …]
  0: Symbol(Symbol.toStringTag)

My best guess is they've been designed to be non-iterable. But why? And how?

Brian Jenkins
  • 358
  • 2
  • 20
  • 1
    [`Object.getOwnPropertyNames(JSON)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames). See [Enumerability and ownership of properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties). Read the documentation about [`Object.getOwnPropertySymbols`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols). – Sebastian Simon Nov 13 '19 at 03:28
  • Damn, I could have sworn I had tried that. Guess this one is pretty open-and-shut. – Brian Jenkins Nov 13 '19 at 03:30

0 Answers0