+ 7
How to pass a Class as a parameter of a function in JS?
Is it possible to pass a class as a argument of function either in pure JS (ES6) or Typescript?
6 Respostas
+ 4
Aaron Sarkissian turns its possible,and ive also found a use,you need functions that accept classes as argument so you can call static methods in them
With this sort of function,you can control which classes are being initialised,which classes methods should get called e.t.c
https://code.sololearn.com/Weu8l4eC8QwP/?ref=app
+ 5
🇳🇬Brains Agree. But this was my friends interview questions.. It was interesting for me too that how we should do it, and why? I'll try to find a case where this can be helpful and the way we should do it.
+ 5
🇳🇬Brains Thanks man. I really appreciate it, good job. 😊
+ 3
goodluck Aaron Sarkissian
+ 2
i doubt its possible,even so i dont think it would be a neccessary feature since i dont think anything might be achievable with that.The general thing is passing an instance of the class(object) as an argument
+ 1
You can do it but why?