// JavaScript - 运行时才发现错误 function add(a, b) { return a + b; } add("1", 2); // "12" - 逻辑错误但未报错 // TypeScript - 编译时就发现错误 function addTS(a: number, b: number): number { return a + b; } addTS("1", 2); // Error: Argument of type 'string' is not assignable to parameter of type 'number'