🎉 JavaScript Tutorial

JavaScript is a powerful programming language that runs in the browser and enables dynamic web content. Whether you're a beginner or looking to refine your skills, this guide will walk you through the essentials.

Basic Syntax

JavaScript code is written in scripts, typically enclosed in <script> tags in HTML.

  • Hello World Example:
    console.log("Hello, World!");  
    
    💻 This snippet outputs "Hello, World!" to the console.

Variables

Use let, const, or var to declare variables.

  • let for mutable variables:
    let message = "Welcome";  
    message = "Hello"; // Valid  
    
  • const for immutable variables:
    const PI = 3.14159;  
    // PI = 3.14; // Invalid (will throw an error)  
    

Data Types

JavaScript supports various data types:

  • Primitive: string, number, boolean, null, undefined, symbol
  • Object: object, array, function, date, etc.

Functions

Functions are reusable blocks of code.

  • Example:
    function greet(name) {  
      return "Hello, " + name + "!";  
    }  
    
    📌 You can call this function with greet("Alice").

Next Steps

Ready to dive deeper? Check out our JavaScript Guide for advanced concepts like closures, promises, and async/await.

variable_declaration
function_definition