How to Pass Function Name as Variable in Javascript

Imagine that we have a javascript function named functionCaller that accept function name as its parameter. Let’s call it callBackFunction. Then, from the inside of functionCaller, we will call the callBackFunction.

function callBackFunction() {
	alert("I'm the callBackFunction..");
}

var functionCaller = function(functionName) {
	functionName();
}

functionCaller(callBackFunction);

Look at how we call the functionCaller. Just pass the function name, which is callBackFunction, as it is. There’s no need to send it as String.