Module 3_JS_part1
Module 3_JS_part1
1. Overview of JavaScript
JavaScript (JS) is a high-level, interpreted programming language that enables interactive web pages. It
is one of the core technologies of the World Wide Web, along with HTML and CSS. JavaScript is used for
client-side scripting, allowing dynamic content updates, form validations, and event-driven
programming.
Page 1
● Communicate with servers using AJAX and Fetch API
Page 2
5. Variables and Data Types
Declaring Variables
Page 3
○ Objects
○ Functions
6. Operators in JavaScript
Arithmetic Operators:
let a = 10;
let b = 5;
console.log(a + b); // Addition: 15
console.log(a - b); // Subtraction: 5
console.log(a * b); // Multiplication: 50
console.log(a / b); // Division: 2
Comparison Operators:
console.log(10 == "10"); // true (type conversion)
console.log(10 === "10"); // false (strict comparison)
console.log(10 > 5); // true
Page 4
7. Functions in JavaScript
JavaScript functions allow code reuse and modularity.
Function Declaration:
function greet(name) {
return "Hello, " + name;
}
console.log(greet("Alice"));
Page 5
Arrow Function (ES6):
const add = (x, y) => x + y;
console.log(add(4, 5));
8. Control Structures
Conditional Statements:
let num = 10;
if (num > 0) {
console.log("Positive number");
} else {
console.log("Negative number");
}
Page 6
Loops:
for (let i = 1; i <= 5; i++) {
console.log("Iteration: " + i);
}
Page 7
9. DOM Manipulation
JavaScript interacts with HTML and CSS via the Document Object Model (DOM).
Page 8