🎉 JavaScript Fundamentals Tutorial
Welcome to the JavaScript basics guide! This tutorial will cover core concepts for beginners.
Table of Contents
Variables & Data Types 💡
JavaScript has several data types including:
number
📐 (e.g., 42, 3.14)string
📝 (e.g., "Hello, world!")boolean
✅ (e.g., true, false)null
🚫 (represents no value)undefined
🤔 (variable declared but not assigned)
Functions 🧠
Use function
keyword to define reusable blocks of code:
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet("Alice")); // Output: Hello, Alice!
Control Structures 🔄
JavaScript supports:
if/else
🌈 for conditional executionfor/while
🌀 for loopsswitch
⚙️ for multiple conditions
Arrays 📁
Arrays store multiple values in a single variable:
let fruits = ["apple", "banana", "cherry"];
console.log(fruits[0]); // Output: apple
Objects 🧩
Objects are key-value pairs:
let person = {
name: "Bob",
age: 30,
greet: function() {
return `Hi, my name is ${this.name}`;
}
};
console.log(person.greet()); // Output: Hi, my name is Bob
For more advanced topics, check out our JavaScript OOP guide!