function func(num) {
if (typeof num === "number") {
console.log(num);
}
else {
throw new TypeError(`必须是一个数组`)
}
}
// 不能使用 try catch来捕获
console.log(func("lll"));
抛出异常的简单处理
最新推荐文章于 2024-08-03 17:05:14 发布