Understand JavaScript and how it works with HTML and CSS.
<script>
alert("Welcome to JavaScript!");
</script>
<script src="script.js"></script>
Variables are used to store data.
JavaScript provides three keywords for declaring variables:
let name = "Ram";
let age = 25;
const website = "My Website";
console.log(name);
console.log(age);
let and const.
Understand var mainly for older JavaScript code.
Learn how JavaScript stores different types of values.
let name = "Ram"; // String
let age = 25; // Number
let isActive = true; // Boolean
let data = null; // Null
let value; // Undefined
String, Number, Boolean, Null, Undefined
Stores related key-value data.
Stores multiple values.
Perform calculations, comparisons and logical operations.
let a = 10;
let b = 5;
console.log(a + b);
console.log(a - b);
console.log(a * b);
console.log(a / b);
| Operator | Meaning |
|---|---|
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
% |
Modulus |
** |
Power |
let age = 20;
console.log(age >= 18);
Learn:
==,
===,
!=,
!==,
>,
<,
>=,
<=
== and ===.
Execute different code based on conditions.
let age = 20;
if (age >= 18) {
console.log("Eligible");
}
if (age >= 18) {
console.log("Adult");
} else {
console.log("Minor");
}
let marks = 75;
if (marks >= 90) {
console.log("Grade A");
} else if (marks >= 60) {
console.log("Grade B");
} else {
console.log("Grade C");
}
Loops repeat code multiple times.
for (let i = 1; i <= 5; i++) {
console.log(i);
}
let i = 1;
while (i <= 5) {
console.log(i);
i++;
}
Functions allow you to reuse code.
function greet() {
console.log("Welcome!");
}
greet();
function greet(name) {
console.log("Hello " + name);
}
greet("Ram");
function add(a, b) {
return a + b;
}
let result = add(10, 20);
console.log(result);
const add = (a, b) => {
return a + b;
};
Store multiple values inside one variable.
let courses = [
"HTML",
"CSS",
"Bootstrap",
"JavaScript"
];
console.log(courses[0]);
courses.forEach(function(course) {
console.log(course);
});
Store related information using key-value pairs.
let student = {
name: "Ram",
age: 25,
course: "Computer Science"
};
console.log(student.name);
student.age = 26;
Work with text and string methods.
let message = "Learn JavaScript";
console.log(message.length);
console.log(message.toUpperCase());
console.log(message.toLowerCase());
console.log(message.includes("Java"));
console.log(
message.replace("JavaScript", "CSS")
);
let name = "Ram";
let message = `Welcome ${name}`;
console.log(message);
Learn how JavaScript interacts with HTML.
<h1 id="heading">
Welcome
</h1>
let heading =
document.getElementById("heading");
heading.innerHTML =
"Welcome to JavaScript";
document.getElementById()
document.querySelector()
document.querySelectorAll()
Change HTML content dynamically using JavaScript.
<p id="message">
Old Message
</p>
<button onclick="changeMessage()">
Change Message
</button>
function changeMessage() {
document.getElementById("message").innerHTML =
"New Message";
}
Old Message
JavaScript responds to user actions.
Common events include:
click change input submit keydown keyup mouseoverlet button =
document.querySelector("#myButton");
button.addEventListener("click", function() {
alert("Button clicked!");
});
Modify styles dynamically.
let text =
document.getElementById("text");
text.style.color = "blue";
text.style.fontSize = "24px";
text.classList.add("highlight");
text.classList.remove("highlight");
text.classList.toggle("highlight");
text.classList.contains("highlight");
Create, add and remove HTML elements dynamically.
let paragraph =
document.createElement("p");
paragraph.innerHTML = "New Paragraph";
document.body.appendChild(paragraph);
paragraph.remove();
Read user input and respond to form actions.
<input
type="text"
id="name"
placeholder="Enter your name">
<button id="submitButton">
Submit
</button>
document
.getElementById("submitButton")
.addEventListener("click", function() {
let name =
document.getElementById("name").value;
alert("Hello " + name);
});
.valuepreventDefault()Check user input before processing a form.
let name =
document.getElementById("name").value;
if (name === "") {
alert("Name is required.");
}
Understand where variables can be accessed.
let globalVariable = "Hello";
function test() {
let localVariable =
"Inside Function";
console.log(localVariable);
}
Handle errors safely in JavaScript programs.
try {
let result = someFunction();
} catch (error) {
console.log(error);
}
try
catch
finally
throw
Learn modern syntax and features.
const website = "My Website";
const square = number => number * number;
let name = "Ram";
console.log(`Hello ${name}`);
const student = {
name: "Ram",
age: 25
};
const { name, age } = student;
const oldArray = [1, 2, 3];
const newArray = [...oldArray, 4];
Work with JSON data used by APIs and applications.
const student = {
name: "Ram",
age: 25
};
JSON.stringify(student);
JSON.parse(jsonData);
Use JavaScript to get data from an API.
fetch("data.json")
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
async function getData() {
try {
const response =
await fetch("data.json");
const data =
await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
}
Store simple data in the browser.
localStorage.setItem(
"username",
"Ram"
);
let user =
localStorage.getItem("username");
localStorage.removeItem("username");
Combine Bootstrap components with JavaScript.
Interactive Bootstrap modals.
Create cards using JavaScript.
Dynamic form validation.
Add and filter table records.
Filter content dynamically.
Control page content.
Learn:
Learn:
Learn:
| Name | Department |
|---|---|
| Ram | Computer |
| Amit | Mathematics |
| Priya | Science |
Use JavaScript to filter rows dynamically.
Build a dynamic image gallery using JavaScript.
Learn:
| Day | Topic |
|---|---|
| Day 1 | Introduction + JavaScript Setup |
| Day 2 | Variables + Data Types |
| Day 3 | Operators + Conditions |
| Day 4 | Loops |
| Day 5 | Functions |
| Day 6 | Arrays |
| Day 7 | Objects + Strings |
| Day 8 | DOM Basics |
| Day 9 | Events + DOM Manipulation |
| Day 10 | Forms + Validation |
| Day 11 | Modern JavaScript ES6+ |
| Day 12 | JSON |
| Day 13 | Fetch API + Async/Await |
| Day 14 | Local Storage |
| Day 15 | Build a Complete JavaScript Project |