[typescript] Function

Suyeon·2020년 11월 11일
0

Typescript

목록 보기
4/12
  • You don't want to use additiolnal type of function, like function add(a, b): number.
function add(num1: number, num2: number) {
	return num1 + num2;
}

Function Type

  • (parameter) => return value
let combineValue: (a: number, b: number) => number;
combineValue = add;

Callback

function handleAdd(n1: number, n2: number, callback: (num: number) => void){
	const result = n1 + n2;
  	callback(result);
}

handleAdd(1, 2, (result) => {
	console.log(result)
});
profile
Hello World.

0개의 댓글