1. syntaxError syntax error
- Irregular variable names:
var 1 = 1; // Uncaught SyntaxError: Unexpected number
var 1a = 1; // Uncaught SyntaxError: Invalid or unexpected number
- Keyword assignment:
new = 1; // Uncaught SyntaxError: Unexpected token =
- Basic syntax error:
var a = 5: // Uncaught SyntaxError: Unexpected token :
2. ReferenceError
- Variable or function is not declared:
fn(); // Uncaught ReferenceError: fn is not defined
- When assigning a value to an object that cannot be assigned:
console.log() = 2; // Uncaught ReferenceError: Invalid left-hand side in assignment
3. RangeError range error
- The array length is assigned a negative number:
var arr = [1, 2, 3];
arr.length = -1; // Uncaught RangeError: Invalid array length
- Object method parameter out of feasible range
var num = 66.66;
num.toFixed(-1); // Uncaught RangeError: toFixed() digits argument must be between 0 and 100
4. TypeError
- Call a method that doesn't exist:
123(); // Uncaught TypeError: 123 is not a function
// Will first judge whether it may be a function, like 123, it cannot be a function, so the type error is reported directly, and if it is a legal function name, a ReferenceError is reported
var obj = {}
obj.say(); // Uncaught TypeError: obj.say is not a function
- Instantiate primitive values:
var a = new 1; // Uncaught TypeError: 1 is not a constructor
5. URIError URI error
URI: URIFORM RESOURCE IDENTIFIER 统一资源标识符
URL: URIFORM RESOURCE LOCATOR 统一资源定位符
URN: URIFORM RESOURCE NAME 统一资源标识符
URI包括URL和URN
decodeURI("%abc"); // Uncaught URIError: URI malformed
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。