Javascript Updated
Javascript Updated
1
Introduction to Scripting
4
Introduction
3
Introduction
4
Introduction
5
Introduction
6
Introduction
7
Introduction
8
Introduction
9
Introduction
10
15
Variables
15
Variables
16
Variables
17
20
Operators
26
Operators
27
Arithmetic operators:
Arithmetic operators are used to perform arithmetic
on numbers
Operators-Arithmetic operators
28
Operators
29
22
Control statements
34
Control statements
35
Control statements
36
If-else Selection statements
37
if
if (condition){
// block of code to be executed if the condition is true
}
If-else
if (condition) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}
If-else Selection statements
38
If-else-if
if (condition1) {
// if condition1 is true
}
else if (condition2) {
// if the condition1 is false and condition2 is true
}
else {
// if the condition1 is false and condition2 is false
}
If-else Selection statements
39
Switch statement
40
Syntax
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
Switch statement
41
JS-Looping structure
42
Syntax: do {
// code block to be executed
}while (condition);
Break and continue
48
Continue
Functions
13
JS Functions
51
JS Functions
52
28
Built-in Functions
56
Built-in Functions
57
Built-in Functions
58
Built-in Functions
59
Scope
28
JS-Scope
61
Example:
JS-Scope
63
Global Scope:
A variable declared outside a function, becomes
GLOBAL
JS-Arrays
64
69
Passing Arrays to functions
70
Displaying Output in Table
71
<html>
<head>
</head>
<body>
<div id ="outone"> </div>
<div id ="outtwo"> </div>
72
Book Example
73
Declaration of array
74
Initialization of array
OUTPUT
Passing Array to Function
76
Output
77
Passing Arrays & converting them to
string
78
Join()
join() method returns the array as a string.
Separator -optional
this method will not change the original array.
Passing Arrays & converting them to
string
79
Join()
join() method returns the array as a string.
Separator -optional
this method will not change the original array.
Passing Arrays & converting them to
string[Book Example]
80
Passing Array to Function
[Book Example cont’d…]
81
JS-Event Handling
82