Try Catch in JavaScript

Try Catch block is used to Capture an error / exception and handle it properly.
Syntax
try
  {
  //Run some code here
  }
catch(err)
  {
  //Handle errors here
  }

Example 1:
<script type="text/javascript">
var errorMsg="";
function message()
{
try
  {
  Alert("Let me alert the user");
  }
catch(err)
  {
  errorMsg="It is not Alert, it has to be alert \n\nThere was an error on this page.\n\n";
  errorMsg+="Error description: " + err.message + "\n\n";
  errorMsg+="Click OK to continue.\n\n";
  alert(errorMsg);
  }
}
</script>