1//passing a function as param and calling that function
2function goToWork(myCallBackFunction) {
3 //do some work here
4 myCallBackFunction();
5}
6
7function refreshPage() {
8 alert("I should be refreshing the page");
9}
10
11goToWork(refreshPage);
1<!DOCTYPE html>
2<html>
3<head>
4 <title>function parameters javascript</title>
5</head>
6<body>
7<button onclick="myfunctionName('rohan')">Click</button>
8
9<script type="text/javascript">
10
11 function myfunctionName(a){
12
13 alert(a);
14
15 }
16
17</script>
18</body>
19</html>