How to create Call back function in Java Script.
Answers (1)
Add AnswerA callback function is one of JavaScript’s superpowers. It is the method through which JavaScript provides a function as an argument to another function. To perform an action, the callback function is invoked in the outer function. Arguments in JavaScript are values that are provided to function parameters. They are only available in the function to which they are provided when that function is invoked. Consider parameters to be variables that hold values in a function.
function greetings(username) { alert('Welcome ' + username); } function saveUserName(callback) { var name = prompt('Please enter your username.'); callback(username); } saveUserName(greetings);
.