Back to Tutorials
JavaScript
20 min read
Sahasransu Satpathy
9/15/2025

JavaScript Basics – Beginner Friendly Tutorial

Learn core JavaScript concepts, syntax, and practical examples for beginners

Introduction

JavaScript is the backbone of modern web development. This guide introduces beginner-friendly concepts, core syntax, and practical examples to help you start coding confidently.

JavaScript Fundamentals

Variables & Data Types

  • var, let, const
  • String, Number, Boolean, Object, Array
let name = "John";
const age = 25;
let isStudent = true;

Functions

  • Function declarations & expressions
  • Arrow functions
function greet(name) {
  return `Hello, ${name}!`;
}
const greetArrow = (name) => `Hi, ${name}!`;

Conditionals & Loops

  • if/else, switch
  • for, while, for-of loops
for(let i = 0; i < 5; i++) {
  console.log(i);
}

Working with Arrays & Objects

  • Array methods: push, pop, map, filter
  • Object properties & methods
const fruits = ["Apple", "Banana", "Cherry"];
fruits.push("Mango");

const person = {
  name: "Alice",
  age: 30,
  greet() { console.log("Hello!"); }
};

DOM Manipulation

  • Selecting elements
  • Changing content & styles
const heading = document.querySelector("h1");
heading.textContent = "Hello JavaScript!";
heading.style.color = "blue";

Event Handling

  • click, input, submit events
const button = document.querySelector("button");
button.addEventListener("click", () => {
  alert("Button clicked!");
});

Mini Project Example

  • To-Do List App
  • Add, delete, and mark tasks complete
  • Practice DOM manipulation and arrays
  • Live demo: View Demo
<input id="taskInput" placeholder="Add a task" />
<button id="addBtn">Add</button>
<ul id="taskList"></ul>
const addBtn = document.getElementById("addBtn");
const taskInput = document.getElementById("taskInput");
const taskList = document.getElementById("taskList");

addBtn.addEventListener("click", () => {
  const li = document.createElement("li");
  li.textContent = taskInput.value;
  taskList.appendChild(li);
  taskInput.value = "";
});

Tips & Best Practices

  • Always use let and const over var
  • Comment your code for clarity
  • Practice small projects daily
  • Learn by building interactive features

Conclusion

By following this tutorial and practicing the examples, you'll gain a solid foundation in JavaScript and be ready for intermediate topics like ES6+, asynchronous programming, and frontend frameworks.


SEO Suggestions:

  • Main keywords: JavaScript tutorial, JS basics, beginner JavaScript guide, learn JS, JS projects
  • Meta description: Learn JavaScript from scratch with beginner-friendly tutorials, examples, mini projects, and practical exercises. Step-by-step guide for 2025.
  • Catchy title suggestions: "JavaScript Basics – Beginner Friendly Tutorial 2025", "Learn JavaScript: Step-by-Step Guide for Beginners"

Previous Tutorial

Browse All Tutorials