What is callback Function ?
A function that you pass into another function, so it can be used (called) later.
1.Bus Travel :
function conductor(ticket){
console.log("where to go");
ticket();
}
function passenger()
{
console.log("Ooty");
}
conductor(passenger);
OUTPUT:
where to go
Ooty
2.G-pay process :
function Gpay(money){
console.log("enter the amount");
money();
}
function PIN(){
console.log("enter the 4 digit PIN");
}
function credit(){
console.log("sucessfully credited");
}
Gpay(PIN);
credit();
OUTPUT:
enter the amount
enter the 4 digit PIN
sucessfully credited
3.Login Process:
function Web(signin){
console.log("Email/Mobile no");
signin();
}
function password(){
console.log("enter your password");
}
function OTP(){
console.log("enter otp");
}
function Login(){
console.log("Sucessfully Login");
}
Web(password);
OTP();
Login();
OUTPUT:
Email/Mobile no
enter your password
enter otp
Sucessfully Login
4.ClassRoom Attendance
function ClassA(attendance){
console.log("Roll no 1");
}
function ask(){
console.log("Aishwarya present");
}
function student1(){
consolee.log("Rool.no 2");
}
function student2(){
console.log("Bharathi present");
}
ClassA(ask);
student1();
student2();
OUTPUT:
Roll.no 1
Aishwarya present
Roll.no 2
Bharathi present
5.ATM Machine Process
function ATM(Transaction){
console.log("domestic/International");
Transaction();
}
function step1(){
console.log("click domestic");
}
function step2(){
console.log("click withdraw");
}
function step3(){
console.log("enter your pin");
}
function step4(){
console.log("enter the amount");
}
function step5(){
console.log("collect your amount");
}
function step6(){
console.log("THANK YOU");
}
ATM(step1);
step2();
step3();
step4();
step5();
step6();
OUTPUT:
Domestic/International
click domestic
click withdraw
enter your pin
enter the amount
collect your amount
THANK YOU
Top comments (0)