实际上,Error 对象只有在被抛出时才会成为异常。 在JavaScript 中抛出异常,可以使用 throw 来抛出 Error 对象: throw TypeError("Expected number"); 或者: throw new TypeError("Expected number"); 来看一个简单的例子: function toUppercase(string) { if (typeof string !== "string") { throw TypeError("E...