
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What is the difference between 'throw new Error' and 'throw someObject' in javascript?
The difference between 'throw new Error' and 'throw someObject' in javascript is that throw new Error wraps the error passed to it in the following format −
{ name: 'Error', message: 'Whatever you pass in the constructor' }
The throw someObject will throw the object as is and will not allow any further code execution from the try block, ie same as throw new Error.
- Related Articles
- What is the difference between throw e and throw new Exception(e) in catch block in java?
- What is the difference between throw and throws keywords in Java?
- Difference between throw and throws in Java
- What is the role of throw statement in JavaScript?
- Throw and throws in Java
- How do we use throw statement in JavaScript?
- Can we re-throw errors in JavaScript? Explain.
- What is the difference between new operator and object() constructor in JavaScript?
- Try, catch, throw and throws in Java
- What is the difference between `new Object()` and object literal notation in JavaScript?
- Why JavaScript 'var null' throw an error but 'var undefined' doesn't?
- Throw Custom Exception in Kotlin
- What is the difference between error () and ajaxError() events in jQuery?
- What is the difference between Flow Control and Error Control?
- Can constructor throw exceptions in Java?

Advertisements