Introduction to JavaScript

JavaScript is a versatile programming language used for web development, server-side scripting, and more. In this tutorial, we’ll cover the basics of JavaScript, including variables, functions, and loops.

Variables

Variables are used to store data. In JavaScript, you can declare a variable using var, let, or const.

let name = "John";
const age = 30;
var isStudent = true;

Functions

Functions are blocks of code designed to perform a particular task. You can define a function using the function keyword.

function greet() {
  console.log("Hello, world!");
}

greet(); // Output: Hello, world!

Loops

Loops are used to execute a block of code repeatedly. The most common types of loops in JavaScript are for and while loops.

for (let i = 0; i < 5; i++) {
  console.log(i);
}

let j = 0;
while (j < 5) {
  console.log(j);
  j++;
}

By understanding these basic concepts, you’ll be well on your way to becoming proficient in JavaScript.