JavaScript (Object-Oriented) ECMA
2024
• DOM Manipulation, Interactivity, and JSON in
Focus
• Presented by: [Your Name]
• College Name: [Your College]
Introduction to JavaScript
• High-level, interpreted language
• Supports Object-Oriented Programming (OOP)
• Modern features in ECMAScript 2024
• Used for web development
Object-Oriented Programming
(OOP)
• Focuses on objects, not actions
• Key principles: Encapsulation, Inheritance, etc.
• JS uses prototype-based OOP
Classes & Constructors
• Introduced in ES6
• A class is a blueprint for objects
Inheritance
• Allows one class to inherit from another
• Use 'extends' and 'super'
Destructuring Arrays & Objects
• Easily extract values from arrays or objects
For...of Loops and Object Iteration
• Loops through iterable objects like arrays
Spread & Rest Operators
• Spread: expands elements
• Rest: collects elements
JavaScript Modules
• Organize code into separate files
• Use 'export' and 'import'
JavaScript DOM
• DOM is the interface for HTML/XML
• JS can manipulate elements in real time
DOM Manipulations
• Access: getElementById, querySelector
• Modify: innerHTML, style
• Add/remove: appendChild, removeChild
JavaScript Interactivity
• Event handling with onclick, keydown, etc.
• Change behavior dynamically
JavaScript Selectors
• Select elements using getElementById,
querySelector, etc.
JavaScript Object Notation (JSON)
• Lightweight data format
• Used for data interchange
Summary
• Modern OOP and UI interaction in JS
• DOM, events, JSON = key web skills
References
• [Link]
• [Link]
• ECMA Official Docs
OOP Example
• let person = {
name: "Alice",
greet() { [Link](`Hi, I'm ${[Link]}`); }
};
[Link]();
Class Example
• class Car {
constructor(brand) {
[Link] = brand;
}
drive() { [Link](`${[Link]} is driving`); }
}
let myCar = new Car("Toyota");
[Link]();
Inheritance Example
• class Animal {
speak() { [Link]("Animal speaks"); }
}
class Dog extends Animal {
speak() { [Link]("Dog barks"); }
}
let d = new Dog();
[Link]();
Destructuring Example
• let [a, b] = [1, 2];
let {name, age} = {name: "Amit", age: 22};
For...of Example
• let fruits = ["apple", "banana"];
for (let fruit of fruits) {
[Link](fruit);
}
Spread/Rest Example
• function sum(...nums) {
return [Link]((a, b) => a + b);
}
let nums = [1, 2, 3];
[Link](sum(...nums));
Modules Example
• // [Link]
export function add(x, y) { return x + y; }
// [Link]
import { add } from './[Link]';
DOM Example
• [Link]("demo").innerText = "Hello DOM!";
DOM Manipulation Example
• [Link](".box").[Link] = "blue";
Interactivity Example
• [Link]("btn").onclick = function() {
alert("Button clicked!");
};
Selector Example
• let el = [Link]("#myId");
[Link] = "green";
JSON Example
• let jsonString = '{"name":"Ravi","age":30}';
let obj = [Link](jsonString);
[Link]([Link]);