0% found this document useful (0 votes)
10 views

js_learning

JavaScript is a versatile programming language primarily used for creating interactive web pages. It includes fundamental concepts such as variables, data types, functions, conditional statements, loops, and DOM manipulation. Mastering JavaScript is crucial for web development and encourages continuous practice to enhance skills.

Uploaded by

raghad mustafa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

js_learning

JavaScript is a versatile programming language primarily used for creating interactive web pages. It includes fundamental concepts such as variables, data types, functions, conditional statements, loops, and DOM manipulation. Mastering JavaScript is crucial for web development and encourages continuous practice to enhance skills.

Uploaded by

raghad mustafa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Introduction to JavaScript

JavaScript is a powerful programming language used to make web pages interactive. It runs in the
browser and can be used for tasks such as handling user input, creating animations, and modifying
webpage content dynamically.

1. JavaScript Basics
Variables
Variables store data that can be used later. In JavaScript, you can declare variables using let,
const, or var.
let name = "John"; // A string variable
const age = 25; // A constant number variable
var city = "New York"; // A variable declared with var (older syntax)

Data Types
JavaScript supports different types of data:
 String: Text ("Hello, World!")
 Number: Numeric values (42, 3.14)
 Boolean: True or false
 Array: A collection of values ([1, 2, 3])
 Object: Key-value pairs ({name: "Alice", age: 30})
Operators
JavaScript includes arithmetic, comparison, and logical operators:
let sum = 5 + 3; // Addition
let isEqual = (10 === 10); // Comparison
let isTrue = (true && false); // Logical AND

2. Functions
Functions allow you to write reusable blocks of code.
function greet(name) {
return "Hello, " + name + "!";
}
console.log(greet("Alice"));

3. Conditional Statements
Use if, else if, and else to control the flow of your code.
let score = 85;
if (score >= 90) {
console.log("Grade: A");
} else if (score >= 80) {
console.log("Grade: B");
} else {
console.log("Grade: C");
}

4. Loops
Loops allow you to execute code multiple times.
for (let i = 0; i < 5; i++) {
console.log("Iteration: " + i);
}

5. DOM Manipulation
JavaScript can modify HTML elements dynamically.
document.getElementById("demo").innerHTML = "Hello, JavaScript!";

Conclusion
JavaScript is an essential language for web development. Keep practicing, and try writing small
scripts to strengthen your understanding!

You might also like