Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

CallBack Function in JavaScript

Uncategorized

In this tutorial, you will learn about JavaScript callback functions with the help of examples.

In JavaScript, you can also pass a function as an argument to a function. This function that is passed as an argument inside of another function is called a callback function.

Example:

// function
function greet(name, callback) {
    console.log('Hi' + ' ' + name);
    callback();
}

// callback function
function callback() {
    console.log('this is callback fundtion');
}

// passing function as an argument
greet('abhishek', callback);

OutPut:

Hi abhishek
this is callback fundtion

In the above program, there are two functions. While calling the greet() function, two arguments (a string value and a function) are passed.

The callback() function is a callback function.

0 0 votes
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] CallBack Function in JavaScript […]

1
0
Would love your thoughts, please comment.x
()
x