这段程序会输出什么?

来自 类型守卫
TypeScript 6 入门 2分钟

这段程序会输出什么?

TypeScript
function describe(value: string | number | undefined): string {
  if (!value) return "empty";
  return typeof value === "string"
    ? value.toUpperCase()
    : value.toFixed(0);
}

console.log(describe(0));
console.log(describe(""));
console.log(describe(3.6));
在试验场中打开
报告错误