The scenario is i am writing some custom javascript method lets say suppose.
function callMe(){
//Do some stuff and return.
}
Now i want to add some functions, i am not sure if they will be treated as callback but which will be triggered at some point as the callMe() is being executed. Lets say i want the beforecallMe() needs to be executed as soon as somebody calls callMe() methof
function beforecallMe(){
// Do something and continue with callMe method
}
Again i want to call a method as soon as the callMe has executed its part of code, lets say method afterCallMe() .
function afterCallMe(){
//Triggered after callMe has executed
}
So is there any possible way i can do this in Callbacks or any other way.
Also i want to know if its possible call other custom functions as callbacks when a particular function is going to execute or has executed, somewhat a trigger.
For e.g : There is a method sendmail() after which i wish to call sometimes sendReport() or startaProgram() or doSomething() and so on. Is there any way to do achieve this ?
I have found answer in the comments as mentioned by Dan Davis in comments.
And the fiddle for the same is
http://jsfiddle.net/3h3f2y93/1/
and Code is :