Lately, I've found myself passing function names as string parameters to another function, checking its existence with typeof
, and calling it if necessary.
I realize as I write this that I could just pass a function reference.
My question is, does the "pass function name as a string" pattern have a common name? And, is it an anti-pattern - should I generally be using references whenever possible?
Aucun commentaire:
Enregistrer un commentaire