Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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()); 
 
PREVIOUS NEXT
Tagged: #typescript #function #parameter
ADD COMMENT
Topic
Name
5+7 =