0

So I have several objects and classes in my script tag

const Main = {}
const App = {}
class Game {}
let state = 777

etc. I'd like to list them.

I've tried Object.keys(Object.getOwnPropertyDescriptors(window)).join(' ')

and

Object.getOwnPropertyNames(window).join(' ')

None of them work, but I'm able to list functions function example() {}

3
  • 1
    This sounds like an XY Problem. For what purpose do you want to list them?
    – Phil
    Commented Jun 12 at 1:58
  • 1
    You probably don't want to, but there are many similar questions on Stackoverflow Getting All Variables In Scope
    – Andy Ray
    Commented Jun 12 at 2:02
  • Um, it's no XY problem, this is exactly what I want! To get a TOC of my old code, with forgotten names.
    – agiopnl
    Commented Jun 12 at 4:30

0

Browse other questions tagged or ask your own question.