Skip to content

Latest commit

 

History

History
58 lines (49 loc) · 1.37 KB

File metadata and controls

58 lines (49 loc) · 1.37 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
throw Statement (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
throw_JavaScriptKeyword
JavaScript
TypeScript
DHTML
error handling, throw statement
throw statement
75cbade0-fb81-4ffe-b187-b71be380bb05
14
mikejo5000
mikejo
ghogen

throw Statement (JavaScript)

Generates an error condition that can be handled by a try...catch...finally statement.

Syntax

throw exception   

Remarks

The required exception argument can be any expression.

The following example throws an error inside a try block, and it is caught in the catch block.

try {  
        throw new Error(200, "x equals zero");  
}  
catch (e) {  
    document.write(e.message);  
}  
  
// Output: x equals zero.  
  

Requirements

[!INCLUDEjsv5]

See Also

try...catch...finally Statement
Error Object