callback function

 it is just a function call inside a  function

console.log("helloworld")


// function multiply(a,s){
//  console.log(a*s)
// }

// function declare(callback){
//  var a=10;
//  var b=30;
//  callback(a,b)

// }
// declare(multiply)// call first you want to do in this case you need to declare and only call multiply



// function multiply(a,s){
//  return a*s
// }

// function declare(callback){
//  var a=10;
//  var b=30;
//  c=callback(a,b)
//  return c
// }
// d=declare(multiply)
// console.log(d)



// function multiply(a,s){
//  console.log(a*s)
// }

// function declare(callback){
//  var a=10;
//  var b=100;
//  callback(a,b)

// }
// declare(function multiply(a,s){
//  console.log(a*s)
// })// call first you want to do in this case you need to declare and only call multiply


// //here you copy the last function to a declaring part also this works
 


// you can write it anonymously

// function declare(callback){
//  var a=10;
//  var b=100;
//  callback(a,b)

// }
// declare(function(a,s){
//  console.log(a*s)
// })// call first you want to do in this case you need to declare and only call multiply
// //dont write ths function name in calling part 




// you can write it with arrow function


function declare(callback){
    var a=10;
    var b=100;
    callback(a,b)

}
declare( (a,s) => {
    console.log(a*s)
})// call first you want to do in this case you need to declare and only call multiply


Comments