pass callback function code example
Example 1: call back function in javascript
function greeting(name) {
alert('Hello ' + name);
}
function processUserInput(callback) {
var name = prompt('Please enter your name.');
callback(name);
}
processUserInput(greeting);
Example 2: how to pass callback function in javascript
function functionOne(x) { alert(x); }
function functionTwo(var1, callback) {
callback(var1);
}
functionTwo(2, functionOne);