JavaScript: The Beginning

Published: (March 2, 2026 at 03:10 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

JavaScript

In 1995, a programmer named Brendan Eich was working at Netscape. At that time, websites were mostly static — they could display information, but they couldn’t really interact with users.

Netscape wanted to make web pages more dynamic and engaging. Brendan Eich was given a task: create a scripting language that would run inside the browser. Incredibly, he built the first version of JavaScript in just 10 days.

What Is JavaScript?

JavaScript is a programming language used to make websites interactive and dynamic. It controls what happens on a webpage. For example, JavaScript makes it possible to:

  • Respond when a user clicks a button
  • Check if a form is filled out correctly (form validation)
  • Show animations and sliders
  • Update content on the page without refreshing it

Without JavaScript, websites would feel static and unresponsive.

Flow Chart: How JavaScript Runs in the Browser

Browser loads HTML

Browser sees <script> tag

Browser sends code to JavaScript Engine

Engine executes the code

Result appears on screen

JavaScript Variables

In JavaScript, a variable is a named container used to store data. Think of it as a labeled box where you keep information so you can use it later in your program.

Instead of repeating a value multiple times in your code, you store it inside a variable and refer to it by name. This makes your code cleaner, easier to read, and simpler to maintain.

let userName = "John";

In this case, userName is the variable, and it stores the value "John". Whenever you use userName in your program, JavaScript will use the stored value.

Why Do We Use Variables?

  • Store values (numbers, text, objects, etc.)
  • Reuse data
  • Update values during program execution

How to Declare Variables in JavaScript

JavaScript provides three ways to declare variables:

  • let
  • const
  • var

What Is let in JavaScript?

let is a keyword used to declare a variable. It was introduced in ES6 (2015) and is now the recommended way to create variables when the value may change later.

let and const

Both let and const only exist inside the block { } where they are declared.

Example with let

if (true) {
  let name = "John";
}

console.log(name); // ❌ ReferenceError: name is not defined

Scope vs Reassignment

  • Scope → Where the variable can be used
  • Reassignment → Whether you can change its value

let can be reassigned, while const cannot be reassigned.

What Is const in JavaScript?

const is used to create a constant variable — a variable that cannot be changed once it has a value.

Example with const

if (true) {
  const age = 25;
}

console.log(age); // ❌ ReferenceError: age is not defined

What Is var in JavaScript?

var is the original way to declare a variable in JavaScript. It has been in the language since the early days (ES5 and earlier), but modern code mostly replaces it with let and const.

A var variable belongs to the function in which it is declared, not to a block scope { }. You can change its value anytime.

0 views
Back to Blog

Related posts

Read more »

The 'skill-check' JS quiz

Question 1: Type coercion What does the following code output to the console? javascript console.log0 == '0'; console.log0 === '0'; Answer: true, then false Ex...