This week we will be discussing JavaScript Events, Functions and Methods.
First we will discuss functions. Function is a named set of statements that performs a task or calculates a value. Functions are fundamental tools in JavaScript. By plugging data into a function, a value will return either to the screen, to a variable, or to another function. Functions enable you to write code and place it into a single unit that can perform a specific task repeatedly throughout the program, as needed in order to use functions effectively,you must know how to:
• Define (or declare) functions.
• Pass arguments to them.
• Call them.
• Return function results.
Defining function:You define a function when you encompass a group of script statements into a function block.
Pass argument to them: The curly braces must encompass any statements that are to execute as part of that function. This statement is known as argument.
Argument: a value or expression containing data or code that is passed on to a function or procedure. Also called a parameter.
Call them: A function's statements are processed when the function is called
Calling Statement: a statement that transfers program execution to a subroutine, procedure or function. Return function results: ends function execution and specifies a value to be returned to the function caller.
Whether they are submitting forms or navigating Web pages, users generate events. JavaScript contains predetermined event handlers that deal with these events. Some of these are mouseOver, mouseOut, reset, select, submit, unload.
The next thing we will discuss is Methods. Methods are what the objects in Javascript can do.
Errors In JavaScript Load-time errors
In relation to a computer programming, scripting or markup language, a "bug" is an error in the code. There are several types of bugs:
Commonly called compiler or interpreter errors, these are typically syntax errors. Load-time errors usually cause error alerts.
Run-time errors — After the script has loaded and is running, an error occurs. These are typically caused by improper use of commands. Run-time errors usually cause error alerts as well.
Logic errors — These are mathematical errors, casting errors, errors in proper command usage or errors in the structure of the script, which result in the script running improperly. Logic errors do not cause error alerts. The script may return unexpected results or may fail to execute at all.
