Master JavaScript programming with our comprehensive tutorial. Learn through practical examples and hands-on coding exercises.
JavaScript is a versatile programming language that enables interactive and dynamic web content. It's essential for modern web development.
// Variables and Data Types
let name = "John";
const age = 25;
var isStudent = true;
// Basic Operations
console.log("Hello, " + name);
console.log(`Age: ${age}`);
Basic JavaScript syntax and string operations
Functions are reusable blocks of code, and control flow determines how your program executes.
// Function Declaration
function greet(name) {
return "Hello, " + name;
}
// Arrow Function
const multiply = (a, b) => a * b;
// Conditional Statements
if (age >= 18) {
console.log("Adult");
} else {
console.log("Minor");
}
Functions, arrow syntax, and conditional statements
Arrays and objects are fundamental data structures in JavaScript for organizing and managing data.
// Arrays
const fruits = ["apple", "banana", "orange"];
fruits.push("grape");
fruits.map(fruit => console.log(fruit));
// Objects
const person = {
name: "John",
age: 25,
hobbies: ["reading", "gaming"],
greet() {
console.log("Hello!");
}
};
Working with arrays and objects in JavaScript