2

What is the difference between throw and throw new Error, I'm a bit confused it seems an Error object is created with just the throw keyword, so why is the new Error used with throw? example

try{
   throw "something went wrong";//this works
}
catch(e){
 console.log(e);
 }


 try{
    throw new Error("something went wrong");//this also works but with    
                                             // longer syntax
 }
 catch(e){
      console.log(e);
 }
Brandon
  • 1,099
  • 1
  • 9
  • 14
  • No, an Error instance is **not** implicitly created by `throw`. The "operand" for `throw` can be any value, and that's what will be available in the `catch` clause. – Pointy Feb 05 '17 at 15:06

0 Answers0