how to pass function as parameter in javascript code example
Example 1: javascript pass function as parameter
function goToWork(myCallBackFunction) {
myCallBackFunction();
}
function refreshPage() {
alert("I should be refreshing the page");
}
goToWork(refreshPage);
Example 2: How to Pass Parameter in JavaScript Function From Html
<!DOCTYPE html>
<html>
<head>
<title>function parameters javascript</title>
</head>
<body>
<button onclick="myfunctionName('rohan')">Click</button>
<script type="text/javascript">
function myfunctionName(a){
alert(a);
}
</script>
</body>
</html>
Example 3: how to create a function with parameters in JavaScript
function name(param, param2, param3) {
}