throw - Throws an Exception in JavaScript

throw statement is used to Create an Exception, it is used in try catch block to generate custom error message or control the flow of code.
Syntax
<script type="text/javascript">
try
  { 
    throw "Err1";
  }
catch(e){
    alert(e);
}
</script>

Example 1 : Throw statement used with Custom Error Message.
<script  type="text/javascript">
try{
    var city="London";

    if(city=="London"){
    throw "Sent out of London";
    }
    else if(city=="Tokyo"){
    throw "Sent out of Tokyo";
    }
    else{
    throw "Sent out of Different City";
    }
} 
catch(e){
    alert("I was "+e);
}
</script>