This way none of your functions get invoked except the one that you explicitly match.
You would probably want to throw a guard condition in there so you don't try to invoke undefined, but this would be my standard approach for anything that needs a dynamic list of functions that have external dependencies.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Not sure about performance, but you can swap the immediate invocation for a
bind
. Eg:This way none of your functions get invoked except the one that you explicitly match.
You would probably want to throw a guard condition in there so you don't try to invoke
undefined
, but this would be my standard approach for anything that needs a dynamic list of functions that have external dependencies.