Answers for "simple function in typescript"

7

types function typescript

interface Safer_Easy_Fix {
    title: string;
    callback: () => void;
}
interface Alternate_Syntax_4_Safer_Easy_Fix {
    title: string;
    callback(): void;
}
Posted by: Guest on January-02-2021
1

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
0

types function typescript

interface Easy_Fix_Solution {
    title: string;
    callback: Function;
}
Posted by: Guest on January-02-2021
0

simple function in typescript

// Named function

//function with type as number
function add(x: number, y: number): number {
  // return sum of numbers entered as params
  return x + y;
}

// Anonymous function

// variable to call and define function
let myAdd = function (x: number, y: number): number {
  // return sum of numbers entered as params
  return x + y;
};
Posted by: Guest on December-30-2020
0

typescript function

// Named function
function add(x: number, y: number): number {
  return x + y;
}

// Anonymous function
let myAdd = function (x: number, y: number): number {
  return x + y;
};
Posted by: Guest on October-06-2020

Code answers related to "simple function in typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language