函数
匿名函数
const names = ["Alice", "Bob", "Eve"];
names.forEach(function (s) {
console.log(s.toLowerCase());
});函数参数
function printToConsole(value: number, key: string) {
return { value, key };
}function printToConsole(
value: number,
key: string
): { value: number; key: string } {
return { value, key };
}
// 这样写起来显得有些太长了,我们将返回值单独拎出来
type ReturnType = { value: number; key: string };
function printToConsole(value: number, key: string): ReturnType {
return { value, key };
}约束参数范围
指定类型参数
可选参数
函数类型参数
剩余参数
函数重载
函数泛型
箭头函数泛型的几种表示方法
最后更新于