Sorry if this has already been answered, but I haven't been able to find the answer myself.
I was wondering if it is possible to create a custom function initializer? Something like this:
const newFunction = customFunction() { // Function code }
Or
customFunction newFunction() { // Function code }
So that whenever the newFunction is called it is possible to run code around the function code. Something like this:
customFunction = {
// Before code
console.log("Starting customFunction")
// Function code
this()
// After code
console.log("Ending customFunction")
}
newFunction()
I hope it makes sense and thanks in advance :)