In Javascript, I have seen the callback function is passed as the last parameter I am curious why so? Is it a good practice or standard way?
For example:
var doSomething = function(fname, lname, callback){
console.log("Your name is :"+ fname +" "+ lname);
callback();
}
var callback = function(){
console.log("Your name is printed successfully."):
}
doSomething('Arpit', 'Meena', callback); // callback is last parameter here
I know we can pass it at any position and it works but I just want to know the reason behind this.
Thanks.