{"id":2125,"date":"2015-01-20T13:15:41","date_gmt":"2015-01-20T11:15:41","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=2125"},"modified":"2018-06-19T10:21:30","modified_gmt":"2018-06-19T07:21:30","slug":"javascript-try-catch-exception-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/","title":{"rendered":"JavaScript Try Catch Exception Example"},"content":{"rendered":"<p><strong>EDITORIAL NOTE<\/strong>: In this post, we feature a comprehensive JavaScript Try Catch Exception Example. The <strong>try<\/strong> statement lets you test a block of code for errors. The <strong>catch<\/strong> statement lets you handle the error.<\/p>\n<p>An important issue to solve, for those of you who use JavaScript as their programming language of choice, is handling errors. They are inevitable and unpredictable and can happen anytime, so this is out of your control (or anyone else&#8217;s control, for that matter), but what you CAN choose is how you handle them. Below, we will show you how exactly you can do that.<\/p>\n<h2>Types of errors<\/h2>\n<p>Before we start getting into details, we have to explain the possible scenarios that may happen. First, errors are divided into two groups: <strong>syntax errors<\/strong> and <strong>exceptions<\/strong>.<\/p>\n<p>Syntax errors are errors made when the programmer accidentally forgets to write a piece of code (which usually are missing closed parentheses or brackets), while exceptions are errors encountered during runtime, due to illegal operations during execution. Examples of these can be undefined functions, undeclared variables and similar things, which may be correct in syntax, but problematic in execution.<br \/>\n[ulp id=&#8217;tCIwOngQUb3zSUuF&#8217;]<\/p>\n<h2>Ways of using the try method<\/h2>\n<p>The most efficient and widespread method to deal with errors in JavaScript is the <code>try<\/code> method. It can be used in three ways:<\/p>\n<ul>\n<li><code>try...catch<\/code><\/li>\n<li><code>try...finally<\/code><\/li>\n<li><code>try...catch...finally<\/code><\/li>\n<\/ul>\n<h2>try&#8230;catch<\/h2>\n<p><code>try... catch<\/code> is the easiest way of using try methods. The <code>try<\/code> clause contains the code that we will try to execute. However, if the method encounters an exception, the execution will stop right then and there, and the exceptions will be suppressed, taking the control right after the <code>try<\/code> block, at the <code>catch<\/code> clause. Let&#8217;s give a look at the example below:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\ntry{\r\n    randomf(x);\r\n    alert('this is an error ')\r\n}\r\ncatch(e){\r\n    alert('x is an undeclared variable')\r\n}\r\n<\/pre>\n<p>We suppose that x is an undeclared variable, so the <code>try<\/code> statement has encountered an exception, so the execution will continue at <code>catch<\/code>. So the results of the piece of code above would be the suppresion of the error.<\/p>\n<p>Let&#8217;s start explaining another important clause that we need in order to fully understand <code>try<\/code> methods. This would be <code>throw<\/code>.<\/p>\n<p><strong>throw<\/strong><\/p>\n<p>The <code>throw<\/code> statement is used inside a <code>try... catch<\/code> statement, and it throws an exception defined by you. The code after <code>throw<\/code> won&#8217;t be executed, and control will be directly transferred to the nearest <code>catch<\/code> statement. Take a look at the code snippet below:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction usernamelengthcheck(){\r\n    try{\r\n        var namelength=prompt(&quot;Enter username length:&quot;)\r\n        if (isNaN(parseInt(namelength)))\r\n            throw new Error(&quot;Please enter a username&quot;)\r\n        else if (namelength&lt;13)\r\n            throw new Error(&quot;Please eneter a longer username.&quot;)\r\n    }\r\n    catch(e){\r\n        alert(e.name+&quot; &quot;+e.message)\r\n    }\r\n}\r\n<\/pre>\n<p>As you can see, we have used <code>try... catch<\/code> and <code>throw<\/code> inside of it, using a very practical example: checking username length. We have used the <code>throw<\/code> statement inside a <code>try<\/code> block that includes an if-else loop, providing us with the possibility of throwing different exceptions for different conditions. After <code>try<\/code> encounters the exception, the control is passed to <code>catch<\/code>, and an alert is triggered, because that is what we&#8217;ve written in that block.<\/p>\n<p>You might have noticed the <code>e.name<\/code> and <code>e.message<\/code> in the alert we&#8217;ve made pop up. Those two are the properties of the error object <code>e<\/code>.<\/p>\n<h2>try&#8230;finally<\/h2>\n<p>The <code>finally<\/code> clause executes whether or not there is an exception thrown. It contains statements to use after the <code>try<\/code> and <code>catch<\/code> are executed. One practical use of them is to close a file you have opened when the <code>try<\/code> block encounters and exception, and you would have to write it like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nopenFile()\r\ntry {\r\n    workOnTheFile(newData);\r\n}\r\nfinally {\r\n    closeFile();\r\n}\r\n<\/pre>\n<p>Usually the <code>finally<\/code> clause is used together with <code>try<\/code> and <code>catch<\/code>. We will show you how in the next section.<\/p>\n<h2>try&#8230; catch&#8230;finally<\/h2>\n<p>Previously we mentioned that the <code>try<\/code> block could be followed by <code>catch<\/code> and <code>finally<\/code>, and also by both at the same time. So how will the method work? Take a look at the code below:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\ntry{\r\n    for (var i=0; i&lt;10; i++){\r\n        if (i==7)\r\n            break\r\n        x=i\r\n    }\r\n}\r\ncatch(e) {\r\n    e.message=&quot;I just caught an exception!!&quot;;\r\n    alert(message);\r\n}\r\nfinally{\r\n    alert(i)\r\n}\r\n<\/pre>\n<p>Here we have put inside <code>try<\/code> a for loop counting from 0 to 9, which breaks when <code>i=7<\/code>. It gives out an alert as soon as it catches the exception, and still the <code>finally<\/code> is executed.<\/p>\n<h2>Nested try blocks<\/h2>\n<p>You can nest a <code>try<\/code> block into another <code>try<\/code> block, into a catch block or into a finally block. The code snippet below shows an example of a <code>try... catch... finally<\/code> nested inside the <code>catch<\/code> block, but you would nest it the same inside the other blocks:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\ntry {\r\n    throw new Error(&quot;error thrown&quot;);\r\n}\r\ncatch (ex) {\r\n    try{\r\n        throw ex;\r\n    }\r\n    catch (ex){\r\n        console.log(&quot;second error thrown is now caught&quot;);\r\n    }\r\n    finally{\r\n        console.log(&quot;finally caught!&quot;);\r\n    }\r\n}\r\n<\/pre>\n<p>You see that in the outer <code>try<\/code> block we have thrown an exception. Then, inside the <code>catch<\/code> block, we insert the whole <code>try... catch... finally<\/code> block. In the inner <code>try<\/code> block we have re-thrown the same exception, we have displayed a message and caught the exception in the <code>catch<\/code> block, and displayed another message in the <code>finally<\/code> block.<\/p>\n<p>Here we have to keep in mind that an exception that has been thrown will be caught by the nearest catch block, and has to be re-thrown in order to be caught again.<\/p>\n<p>The output to the code above will be:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/second error is now caught\r\n\/\/error thrown\r\n\/\/finally caught\r\n\/\/error thrown\r\n<\/pre>\n<h2>Using try\/catch blocks in real life<\/h2>\n<p>Take a look at the code below:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;Guessing game!&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;p&gt;Guess my username length to win a prize!&lt;\/p&gt;\r\n\r\n&lt;button type=&quot;button&quot; onclick=&quot;usernamelengthcheck()&quot;&gt;Trigger prompt&lt;\/button&gt;\r\n&lt;p id=&quot;message&quot;&gt;&lt;\/p&gt;\r\n\r\n&lt;script&gt;\r\n    function usernamelengthcheck(){\r\n        try{\r\n            var namelength=prompt(&quot;Enter username length:&quot;)\r\n            if (isNaN(parseInt(namelength)))\r\n                throw new Error(&quot;Input should be a number&quot;)\r\n            else if (namelength&gt;3)\r\n                throw new Error(&quot;Please enter another username length.&quot;)\r\n        }\r\n        catch(e){\r\n            alert(e.name+&quot; &quot;+e.message)\r\n        }\r\n    }\r\n&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Using the code, we have asked the user to guess the length of a username provided before and we throw errors based on the answer we get from the prompt. This code can be used in password recovery processes.<\/p>\n<h2>Download the source code<\/h2>\n<p>This was an example of try\/catch in JavaScript.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/01\/TryCatch1.zip\">TryCatch<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>EDITORIAL NOTE: In this post, we feature a comprehensive JavaScript Try Catch Exception Example. The try statement lets you test a block of code for errors. The catch statement lets you handle the error. An important issue to solve, for those of you who use JavaScript as their programming language of choice, is handling errors. &hellip;<\/p>\n","protected":false},"author":25,"featured_media":920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript Try Catch Exception Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn about JavaScript Try Catch Exception? Check out our Example where we tackle the inevitable and unpredictable issue of handling errors.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Try Catch Exception Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about JavaScript Try Catch Exception? Check out our Example where we tackle the inevitable and unpredictable issue of handling errors.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/era.balliu.7\" \/>\n<meta property=\"article:published_time\" content=\"2015-01-20T11:15:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-19T07:21:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Era Balliu\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BalliuEra\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Era Balliu\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/\"},\"author\":{\"name\":\"Era Balliu\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e\"},\"headline\":\"JavaScript Try Catch Exception Example\",\"datePublished\":\"2015-01-20T11:15:41+00:00\",\"dateModified\":\"2018-06-19T07:21:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/\"},\"wordCount\":1101,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/\",\"name\":\"JavaScript Try Catch Exception Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2015-01-20T11:15:41+00:00\",\"dateModified\":\"2018-06-19T07:21:30+00:00\",\"description\":\"Interested to learn about JavaScript Try Catch Exception? Check out our Example where we tackle the inevitable and unpredictable issue of handling errors.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript Try Catch Exception Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e\",\"name\":\"Era Balliu\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f6adddf7eada210f682608fea9d8159441369ec622998a5851a447e0a2bfa3f3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f6adddf7eada210f682608fea9d8159441369ec622998a5851a447e0a2bfa3f3?s=96&d=mm&r=g\",\"caption\":\"Era Balliu\"},\"description\":\"Era is a Telecommunications Engineering student, with a great passion for new technologies. Up until now she has been coding with HTML\/CSS, Bootstrap and other front-end coding languages and frameworks, and her recent love is Angular JS.\",\"sameAs\":[\"http:\/\/www.webcodegeeks.com\/\",\"https:\/\/www.facebook.com\/era.balliu.7\",\"https:\/\/www.instagram.com\/eraballiu\/\",\"https:\/\/www.linkedin.com\/in\/eraballiu\",\"https:\/\/www.pinterest.com\/001r2gw0jt0ln6d\/\",\"https:\/\/x.com\/BalliuEra\",\"https:\/\/www.youtube.com\/c\/eraballiu\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/era-balliu\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Try Catch Exception Example - Web Code Geeks - 2026","description":"Interested to learn about JavaScript Try Catch Exception? Check out our Example where we tackle the inevitable and unpredictable issue of handling errors.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Try Catch Exception Example - Web Code Geeks - 2026","og_description":"Interested to learn about JavaScript Try Catch Exception? Check out our Example where we tackle the inevitable and unpredictable issue of handling errors.","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/era.balliu.7","article_published_time":"2015-01-20T11:15:41+00:00","article_modified_time":"2018-06-19T07:21:30+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","type":"image\/jpeg"}],"author":"Era Balliu","twitter_card":"summary_large_image","twitter_creator":"@BalliuEra","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Era Balliu","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/"},"author":{"name":"Era Balliu","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e"},"headline":"JavaScript Try Catch Exception Example","datePublished":"2015-01-20T11:15:41+00:00","dateModified":"2018-06-19T07:21:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/"},"wordCount":1101,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/","name":"JavaScript Try Catch Exception Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2015-01-20T11:15:41+00:00","dateModified":"2018-06-19T07:21:30+00:00","description":"Interested to learn about JavaScript Try Catch Exception? Check out our Example where we tackle the inevitable and unpredictable issue of handling errors.","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-try-catch-exception-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Try Catch Exception Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/c27ecf40c810e6396ba93ffb829c7b0e","name":"Era Balliu","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f6adddf7eada210f682608fea9d8159441369ec622998a5851a447e0a2bfa3f3?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f6adddf7eada210f682608fea9d8159441369ec622998a5851a447e0a2bfa3f3?s=96&d=mm&r=g","caption":"Era Balliu"},"description":"Era is a Telecommunications Engineering student, with a great passion for new technologies. Up until now she has been coding with HTML\/CSS, Bootstrap and other front-end coding languages and frameworks, and her recent love is Angular JS.","sameAs":["http:\/\/www.webcodegeeks.com\/","https:\/\/www.facebook.com\/era.balliu.7","https:\/\/www.instagram.com\/eraballiu\/","https:\/\/www.linkedin.com\/in\/eraballiu","https:\/\/www.pinterest.com\/001r2gw0jt0ln6d\/","https:\/\/x.com\/BalliuEra","https:\/\/www.youtube.com\/c\/eraballiu"],"url":"https:\/\/www.webcodegeeks.com\/author\/era-balliu\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=2125"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/2125\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=2125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=2125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=2125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}