Hello js devs in this tutorial i will show you how to pass function as a parameter in JavaScript. Sometimes we need to pass function as a parameter in JavaScript. But do you know the way of passing function as a parameter in JavaScript.
In this example i will share the code of javascript pass function as parameter with arguments. See the below example of code:
var x = function() {
console.log("Hello..");
}
var y = function(callback) {
callback();
}
y(x);
Output of this code will be
Read also : How to Detect User Has Checked or Unchecked a Checkbox in JavaScript
Hope it can help you.
#javascript