首页 / / {{ Title }}
{{ Title }}
type NumOrStr = number | string;
function safeAdd(a: NumOrStr, b: NumOrStr): number {
return Number(a) + Number(b);
}
console.log(safeAdd(1, 1));
console.log(safeAdd("1", "1"));
console.log(safeAdd(1, "1"));
comment
共有 0 条评论