js error object code example
Example 1: js throw error
throw new Error('Whoops!')
Example 2: try catch in javascript
try {
}
catch(err) {
}
finally {
}
Example 3: javascript how to raise the error
if (..condition..) {
throw 'Error message';
}
Example 4: javascript try
var someNumber = 1;
try {
someNumber.replace("-","");
} catch(err) {
console.log(err);
}
Example 5: javascript throw new error
throw new Error("Error message here");
Example 6: js errors
JS Error Name Values:
name
Sets or returns the error name
message
Sets or returns an error message in string from
EvalError
An error has occurred in the eval() function
RangeError
A number is “out of range”
ReferenceError
An illegal reference has occurred
SyntaxError
A syntax error has occurred
TypeError
A type error has occurred
URIError
An encodeURI() error has occurred