Best Cosmetic Hospitals Near You

Compare top cosmetic hospitals, aesthetic clinics & beauty treatments by city.

Trusted • Verified • Best-in-Class Care

Explore Best Hospitals

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.

Best Cardiac Hospitals Near You

Discover top heart hospitals, cardiology centers & cardiac care services by city.

Advanced Heart Care • Trusted Hospitals • Expert Teams

View Best Hospitals
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