Welcome to the HTML section of JD Academy! In this module, you'll embark on a journey to master the fundamental language of the web—HTML. As the backbone of every web page, HTML allows you to structure content and create a seamless browsing experience for users.
Creation (1995): JavaScript was created by Brendan Eich at Netscape and was originally named "Mocha" then "LiveScript" before settling on "JavaScript."
Browser Wars (1995-2000): Microsoft's JScript and Netscape's JavaScript competed during the browser wars, leading to some fragmentation.
ECMAScript (1997-present): Efforts were made to standardize JavaScript, leading to the creation of ECMAScript. ECMAScript 6 (ES6) in 2015 introduced significant enhancements.
Client-Side Interactivity: JavaScript enables dynamic, client-side interactivity.
Asynchronous Programming: The introduction of Promises and async/await in ES6 improved asynchronous programming.
Full-Stack Development: JavaScript is now used on both the client and server sides with technologies like Node.js.
Browser Compatibility: Ensuring cross-browser compatibility remains a challenge.
Security Concerns: Being executed on the client side exposes JavaScript to security risks like cross-site scripting (XSS).
Callback Hell: Prior to ES6, managing asynchronous code could lead to callback hell. Modern solutions like Promises and async/await have addressed this to some extent.
JavaScript is a versatile, high-level programming language primarily used for building dynamic and interactive web pages. It allows developers to manipulate the content, structure, and behavior of a webpage.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<h1>Hello, JavaScript!</h1>
<script>
// Internal JavaScript code
console.log("Hello, JavaScript!");
</script>
</body>
</html>
Variables are containers for storing data. In JavaScript, you can use 'var', 'let', or 'const' to declare variables.
JavaScript supports various data types, including numbers, strings, booleans, arrays, and objects.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<script>
// Internal JavaScript code
var age = 25;
let name = "John";
const PI = 3.14;
var number = 42;
var text = "Hello, World!";
var isTrue = true;
var fruits = ['apple', 'banana', 'orange'];
var person = { name: 'John', age: 30 };
</script>
</body>
</html>
Used to execute a block of code if a specified condition is true.
A multi-case decision-making structure.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<script>
// Internal JavaScript code
var age = 18;
if (age >= 18) { console.log("You are an adult."); }
else {
console.log("You are a minor.");
}
var day = "Monday";
switch (day) {
case "Monday":
console.log("It's the start of the week."); break;
// ... other cases
}
</script>
</body>
</html>
Executes a block of code a specified number of times.
Repeatedly executes a block of code as long as a specified condition is true.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<script>
// Internal JavaScript code
for (var i = 0; i < 5; i++) {
console.log("Iteration: " + i); }
var count = 0;
while (count < 3) {
console.log("Count: " + count);
count++;
}
</script>
</body>
</html>
A set of instructions grouped together to perform a specific task.
A concise way to write functions in JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<script>
// Internal JavaScript code
function greet(name) { console.log("Hello, " + name + "!"); }
greet("John");
const square = (num) => num * num;
console.log(square(5));
</script>
</body>
</html>
Interacting with HTML elements using JavaScript.
Modifying the content and attributes of HTML elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<h1 id="main-heading">Original Heading</h1>
<script>
// Internal JavaScript code
var heading = document.getElementById
("main-heading");
heading.innerHTML = "New Heading";
</script>
</body>
</html>
Responding to user actions on a webpage.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<button id="myButton">Click Me</button>
<script>
// Internal JavaScript code
var button = document.getElementById("myButton");
button.addEventListener("click", function() {
console.log("Button clicked!");
});
</script>
</body>
</html>
Creating and working with objects.
Defining and using classes in JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<script>
// Internal JavaScript code
var car = {
brand: "Toyota",
model: "Camry",
year: 2022,
start: function() {
console.log("Engine started!");
}
};
class Animal {
constructor(name) {
this.name = name;
}
speak() {
console.log(this.name + " makes a sound.");
}
}
var dog = new Animal("Dog");
dog.speak();
</script>
</body>
</html>
Handling asynchronous operations using callbacks.
Managing asynchronous tasks with promises.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<style>
/* Internal CSS code */
body { font-family: 'Arial', sans-serif; }
</style>
</head>
<body>
<script>
// Internal JavaScript code
function fetchData(callback) {
setTimeout(function() {
var data = "Fetched data";
callback(data);
}, 2000);
}
fetchData(function(result) {
console.log(result);
});
function fetchDataPromise() {
return new Promise(function(resolve, reject) {
setTimeout(function() {
var data = "Fetched data";
resolve(data);
}, 2000);
});
}
fetchDataPromise()
.then(function(result) {
console.log(result);
})
.catch(function(error) {
console.error(error);
});
</script>
</body>
</html>
Objective: Create an interactive quiz application with multiple-choice questions.
Objective: Build a to-do list application with the ability to add, edit, and delete tasks.
Objective: Develop an image slider that automatically cycles through a set of images.
Objective: Create a weather application that fetches and displays weather information based on user input.
Objective: Build a classic memory game where users match pairs of cards.
“Don't comment bad code - rewrite it.”