Answers for "passing type as parameter typescript"

2

typescript function as parameter

function createPerson(name: string, doAction: () => void): void {
  console.log(`Hi, my name is ${name}.`);
  doAction(); // doAction as a function parameter.
}

// Hi, my name is Bob.
// performs doAction which is waveHands function.
createPerson('Bob', waveHands());
Posted by: Guest on December-03-2020

Code answers related to "passing type as parameter typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language