How to pass a runnable procedure (a function) as a parameter and run it in TypeScript

1 Answer

0 votes
function runnableProcedure(f: any): void {
  f(); // Execute the passed function
}
 
// Define a function to pass
function say() {
  console.log("xyz");
}
 
// Pass the function as a parameter
runnableProcedure(say);
 
 
 
/*
run:
 
"xyz" 
 
*/

 



answered May 22, 2025 by avibootz
...