Knowledge check: Error handling in Javascript

Knowledge check: Error handling in Javascript

  1. What will be printed when the following code runs?

     var result = null;
     console.log(result);
    
    • undefined

    • null

    • 0

  2. When the following code runs, what will print out?

     try {
       console.log('Hello');
     } catch(err) {
       console.log('Goodbye');
     }
    
    • Hello

    • Goodbye

  3. If you pass an unsupported data type to a function, what error will be thrown?

    • RangeError

    • SyntaxErrror

    • TypeError

  4. What will print out when the following code runs?

     var x;
    
     if(x === null) {
       console.log("null");
     } else if(x === undefined) {
       console.log("undefined");
     } else {
       console.log("ok");
     }
    
    • null

    • undefined

    • ok

  5. What will print out when the following code runs?

     throw new Error();
     console.log("Hello");
    
    • Hello

    • Nothing will print out.