Web Programming Unit1
Web Programming Unit1
Learning Objectives
1. Features of JavaScript
JavaScript is a scripting language designed primarily for creating interactive and dynamic web content. It
runs on the client side, meaning it is processed by the user's web browser rather than the server.
Key Features:
JavaScript can be written inside an HTML document or in external files with .js extension. Basic syntax
includes the use of semicolons, variables, and functions.
<script>
alert("Welcome to JavaScript!");
</script>
Rules:
• Case-sensitive
• Statements end with ;
• Blocks are enclosed in {}
1
Example of a simple program:
JavaScript supports different kinds of data for storing and manipulating values.
4. Operators in JavaScript
Categories of Operators:
• Arithmetic: + , - , * , / , %
• Assignment: = , += , -= , *=
• Comparison: == , === , != , > , < , >= , <=
• Logical: && (and), || (or), ! (not)
• Bitwise: & , | , ^ , ~ , << , >>
Example:
2
5. Control Structures
Control structures determine how the flow of execution moves through the code.
Conditional Statements:
Example:
Loops:
Jump Statements:
6. Dialog Boxes
Example:
7. Functions in JavaScript
Syntax:
3
function functionName(parameters) {
// code block
}
Example:
function greet(name) {
return "Hello " + name;
}
console.log(greet("Alice"));
Types of Functions:
8. Arrays
Declaration:
Common Methods:
The DOM is a programming interface for web documents. It represents the page structure as a tree of
objects.
4
• Modify content ( innerHTML , textContent )
• Change styles, attributes, or structure
Example:
Object Purpose
JavaScript allows creation of custom objects using constructor functions and the this keyword.
Example:
5
Common Events:
Example:
document.getElementById("btn").onclick = function() {
alert("Button clicked!");
};
Reference Books
1. Dr. S.B. Kishor et al., "Web Designing (HTML, JavaScript & VBScript)", Das Ganu Prakashan
2. Ian Pouncey & Richard York, "Beginning CSS", Wiley India
3. Lee Purcell & Mary Jane Mara, "The ABCs of JavaScript"