The 1.break statement is used to jump out of a loop. After the break statement jumps out of the loop, the code after the loop continues to execute, if any. The Continue is used to skip an iteration in the loop.
2 . Label:statements is used to jump directly to the line specified by the identifier and start execution, which can only be used by break and continue.
The 3.try statement tests the code block for errors. The catch statement handles the error. The throw statement creates a custom error.
Try { // Run code here }catch(err) { /// Handling errors here }
The throw statement allows us to create custom errors.
Syntax: Throw Exception
<script>function MyFunction () {Try { varX=document.getelementbyid ("Demo"). Value; if(x=="")Throw "Empty"; if(IsNaN (x))Throw "Not a number"; if(x>Ten)Throw "too high"; if(x<5)Throw "too Low"; }Catch(err) {varY=document.getelementbyid ("mess"); Y.innerhtml="Error:"+ Err +"."; }}</script>5andTen: </p><input id="Demo"Type="text"><button type="Button"onclick="myFunction ()">test input</button><p id="mess"></p>
4.JavaScript can be used to validate these input data in an HTML form before the data is sent to the server.
These typical forms of data that are validated by JavaScript are:
Has the user filled out the required fields in the form?
is the email address entered by the user legal?
Has the user entered a valid date?
Does the user enter text in the Data field (numeric field)?
Javascript/15-1-14