Both are fine; this is explicitly stated in the specification:
… Thus the function call
Error(…)
is equivalent to the object creation expressionnew Error(…)
with the same arguments.
More Related Contents:
- What’s a good way to extend Error in JavaScript?
- How do I create a custom Error in JavaScript?
- JavaScript Exception Handling
- Is it possible to catch exceptions thrown in a JavaScript async callback?
- alias to chrome console.log
- In Javascript, is it expensive to use try-catch blocks even if an exception is never thrown?
- Custom exception type
- Javascript exception stack trace
- Javascript Asynchronous Exception Handling with node.js
- How to catch net::ERR_CONNECTION_REFUSED
- Why doesn’t the try catch block catch the promise exception?
- What is the max size of localStorage values?
- Remove array element based on object property
- How to detect my browser version and operating system using JavaScript?
- Parsing a string to a date in JavaScript
- How to format numbers as currency strings
- Format date in a specific timezone
- Input placeholders for Internet Explorer
- How to disable browser developer tools?
- How to open a native iOS app from a web app
- Scroll with anchor without # in URL
- Tool to track down JavaScript memory leak
- Suites vs Specs Protractor
- Get object property name as a string
- Can I use jQuery to check whether at least one checkbox is checked?
- Changing getJSON to JSONP
- Why does the logical or operator (||) with an empty arrow function (()=>{}) cause a SyntaxError?
- hide open/active accordion when another accordion is clicked
- javascript function name cannot set as click?
- Javascript Tilde & Two’s complement