0

Imagine that I created a class. And now how can I find it (or all other classes) and in which scope?

class TestClass {
}

Object.getOwnPropertyNames(this).includes('TestClass'); // false

The returned value is false but I expected that last expression will return true. Is it even possible to find defined classes?

MutMutrina
  • 57
  • 1
  • 6
  • So to get this correct, you want to get a list of EVERY class in scope? if so why? if you want to select between certain classes use something like https://stackoverflow.com/a/59454685/8355065 – herohamp Dec 23 '19 at 11:45
  • classes are not added to the `window`, so it won't have the TestClass on it. Why do you need to do this in the first place – Nick Parsons Dec 23 '19 at 11:50
  • @NickParsons I just want to find all custom classes in the global scope – MutMutrina Dec 23 '19 at 12:02
  • Nearly all native functions can be constructors and hence can be "classes". How will you distinguish between a plan function and a class function? – RobG Dec 23 '19 at 12:09

0 Answers0