<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
JavaScript For...In Statement
The for...in statement loops through the elements of an array or through the properties of an object.
Syntax
for (variable in object)
{
code to be executed
}
The code in the body of the for...in loop is executed once for each element/property.
Events are actions that can be detected by JavaScript.
Every element on a web page has certain events which can trigger a JavaScript. For example, we can use the onClick event of a button element to
indicate that a function will run when a user clicks on the button. We define the events in the HTML tags.
Examples of events:
A mouse click
A web page or an image loading
Mousing over a hot spot on the web page
Selecting an input field in an HTML form
Submitting an HTML form
A keystroke
The try...catch statement allows you to test a block of code
for errors.
The try...catch Statement
The try...catch statement allows you to test a block of code for errors. The try block contains the code to be run, and the catch block contains the code to be
executed if an error occurs.
Syntax
try
{
//Run some code here
}
catch(err)
{
//Handle errors here
}
Note that try...catch is written in lowercase letters. Using uppercase letters will generate a JavaScript error!
The throw Statement
The throw statement can be used together with the try...catch statement, to
create an exception for the error
The Throw Statement
The throw statement allows you to create an exception. If you use this statement together with the try...catch statement, you can control program
flow and generate accurate error messages.
Syntax
throw exception
throw is written in lowercase letters. Using uppercase letters will generate a JavaScript error!