JavaScript
JavaScript
OBJECT IN JAVASCRIPT
JavaScript is an object based Language. It treats each of the elements of web
page as an object. They are grouped according to their type and purpose.
Document: corresponds to the current web page’s body. Using this we can have
access to the html of the page it self, including all the links, images and anchors.
Form: holds information about html forms in the current page; forms can
contain buttons, text fields and all kinds of other html elements.
Frame: refers to the frame in browser window.
History: holds the record of the sites the web browser has visited before
reaching the current page. Gives you access to methods that let you move to
previous pages.
Location: holds information about the location of the current web page, such as
its URL, the domain name, path, server port and more.
Navigator: refers to the browser itself, letting you determine what browser the
user has.
Window: refers the current browser window.
Properties:
An object has its own characteristic that makes it unique within a group. Some
characteristic or properties are common to many objects while other are
specified to each one.
The Syntax for properties is:
Object. properties
Document.bgcolor
Method:
Most objects have special function called methods that executes some operation
related to the object. The basic syntax is:
Object. Method (arguments)
Events:
An event determines the object reaction to external condition. They are
recognized by object and handled application. An event occur through user
action such as Mouse Click on Button or entering the content of a field
Function:
Functions are predefined routines built for a specific task. They are different
from methods, as they are not associated with an object. JavaScript has generic
function for various tasks.
Operator:
The Symbol that is used to represent a particular operation on some operands is
called operator.
The Script Tag:
The browser is give the information about an embedded JavaScript into an
HTML file using the HTML tag pair <script></script>
It has only one attributes that is LANGUAGE; each indicates which scripting
language is used.
Syntax:
<Script language=”JavaScript”>
java script code
</script>
Variable:
A variable is a placeholder we can store our data and information. it is a name
of location of memory when the constant is stored. JavaScript allow you to
declare a variable and use the value stored in them. In JavaScript we can declare
a variable using the VAR keyword.
Ex:
Var name;
Var mark;
Var age;
Var adr
Programming Construct:
The control statement enables us to specify the order in which the various
instructions in a program are o. In other word the control statement determine
the flow of control in a program. In JavaScript control statement are of two
types:
1. Conditional Control Statement
2. Loop Control Statement
Conditional Control Statement:
The construct provides facility to execute a person of program only once
based on a condition. The conditional constructors are:
1. if …… Else
2. Switch Case
If……………Else:
The primary decision making construct of any programming language is IF.
This construct allow for the conditional branching of the code.
Syntax:
If (condition)
{
Statement;
Statement;
}
Else
{
Statement
Statement
}
Switch Case:
This control statement allows us to make a decision from number of choice.
This is basically use to replace multiple if function
Syntax:
Switch (condition)
{
Case “constant” or int const:
{
Statement for case 1;
Break;
}
Case “constant” or int const:
{
Statement for case 2;
Break;
}
Case “constant” or int “const”:
{
Statement for case 3;
Break;
}
………..
………..
………..
Default:
{
Statement for default;
}
}
Loop Construct:
Loop construct is the ability to perform set of instruction repeatedly. This
involve repetinting some person of program either a specific number of time or
until a particular condition is satisfied. This repetitive done through a loop
control statement. There are twi type of loop in JavaScript.
1. For Loop
2. while Loop
For Loop:
For is a loop statement where a statement can be executed as per the
condition and it could not terminated till the condition become satisfied.
Syntax:
For(initialize counter; condition check; increment or decrement counter)
ARRAY:
Array are order collection of a value refer by a single variable name.
Ex:
Num [5]
Num [0]=Jitesh
Num [1]=chandan
Num [2]=Jitesh
Num [3]=sanjay
Num [4]=bikash