22
May 10

How to dynamically call javascript functions

I’ve had a lot of moments when I needed to call a javascript function dynamically. By dynamic function call in javascript, I mean when you do not know the function name to be called before hand i.e. the function name to be executed is provided at runtime.

All you need to do is – window["functionname"]();

Yeah, that’s all! Here functionname would be replaced with the name of your function. As always, I’ll provide a working example so that there is no confusion as to how to make dynamic function calls in Javascript.