javascript pass function as parameter
//passing a function as param and calling that function
function goToWork(myCallBackFunction) {
//do some work here
myCallBackFunction();
}
function refreshPage() {
alert("I should be refreshing the page");
}
goToWork(refreshPage);<!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>
Also in JavaScript:
- add dev dependency yarn
- nodejs add element to array
- react native dynamic view size
- parsefloat jquery
- jwt refresh token
- post method javascript code
- recursive function javascript
- angular datatable reload with pagination
- react redux npm
- nodejs express routing
- javascript random number
- créer composant react
- how to make react router Link active
- javascript recursive fibonacci
- es6 js slug from string
- remove floating point javascript
- how to get csrf token in javascript
- js get object by id from array
- count characters in typescript
- javascript set class
- javascript w3schools
- [JsonConverter(typeof(StringEnumConverter))] on list of enums
- pass header in ajax
- javascript replace all occurrences of string