Custom Error throw

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>自定义错误throw</title>
    <!-- 
        throw a;
        Interpretation:
        After throwing error, and custom error messages a, a is the error message prompts
        Use catch (b) to capture error messages b, b is the custom error name, also known accommodate the wrong target

        Remember: When an error is generated, JavaScript can actually create an Error object with two properties: name and message.
     -> 
</ head > 
< body > 
    < Script > 
        var A = . 1 ;
         the try {
             the throw  " I error " ; // custom Massage error 
        }
         the catch (B) { // the catch () capturing error name = b 
            the console.log (B); // B receiving the throw Massage defined error 
        }
     </ Script > 
</ body > 
</ HTML >

Guess you like

Origin www.cnblogs.com/vinson-blog/p/12040320.html