What is the difference between `throw new Error` and `throw someObject`?
问题 I want to write a common error handler which will catch custom errors thrown on purpose at any instance of the code. When I did throw new Error(\'sample\') like in the following code try { throw new Error({\'hehe\':\'haha\'}); // throw new Error(\'hehe\'); } catch(e) { alert(e); console.log(e); } Log shows in Firefox as Error: [object Object] and I couldn’t parse the object. For the second throw the log shows as: Error: hehe Whereas when I did try { throw ({\'hehe\':\'haha\'}); } catch(e) {