1try {
2 throw new TypeError('Hello', "someFile.js", 10)
3} catch (e) {
4 console.log(e instanceof TypeError) // true
5 console.log(e.message) // "Hello"
6 console.log(e.name) // "TypeError"
7 console.log(e.fileName) // "someFile.js"
8 console.log(e.lineNumber) // 10
9 console.log(e.columnNumber) // 0
10 console.log(e.stack) // "@Scratchpad/2:2:9\n"
11}
1try {
2 null.f()
3} catch (e) {
4 console.log(e instanceof TypeError)
5 console.log(e.message)
6 console.log(e.name)
7 console.log(e.fileName)
8 console.log(e.lineNumber)
9 console.log(e.columnNumber)
10 console.log(e.stack)
11}
1//Occurs when trying to use a value in an invalid way.
2
31();
4
5/*The numeric value 1 is not a function, so trying to use it as one
6results in TypeError: 1 is not a function.*/
1try {
2 null.f()
3} catch (e) {
4 console.log(e instanceof TypeError)
5 console.log(e.message)
6 console.log(e.name)
7 console.log(e.fileName)
8 console.log(e.lineNumber)
9 console.log(e.columnNumber)
10 console.log(e.stack)
11}
120
13