How to pass a function as a parameter in TypeScript

1 Answer

0 votes
function f() {
    return 'function f()';
}
 
function test(s, f) {
    const message = f();
 
    console.log(`${s} ${message}`);
}
 
test('eee', f);
test('vvv', f);
 
 
 

 
/*
run:
 
"eee function f()" 
"vvv function f()" 
 
*/

 



answered Jan 29, 2022 by avibootz
...