Ticker

6/recent/ticker-posts

JavaScript Part 1: The Story Behind the Language That Powers the Modern Web

Imagine opening your favorite website.

You click a button.

A menu appears instantly.

You submit a form and receive a response without the page refreshing.

You watch videos, chat with friends, shop online, or scroll endlessly through social media feeds.

Behind almost every one of these interactions is a programming language called JavaScript.

Today, JavaScript powers billions of websites and applications around the world. Whether you're using YouTube, Facebook, Netflix, Amazon, or Google Maps, JavaScript is working behind the scenes to make the experience smooth and interactive.

But here's something surprising.

The language that now dominates web development wasn't created over years by a huge engineering team.

It was created in just 10 days.

Yes, only ten days.

In this article, we'll explore the fascinating history of JavaScript, understand why it became so popular, and learn some of its most important fundamentals in a simple and practical way.

This article is designed for beginners who want to build a strong foundation before diving into advanced JavaScript concepts.


Javascript part one: whosgeek


The Birth of JavaScript: A Ten-Day Revolution

Let's travel back to 1995.

The internet was still young.

Most websites were simple pages containing text and images.

They looked more like digital brochures than the interactive applications we use today.

At that time, a company called Netscape dominated the browser market.

Netscape wanted a way to make websites more interactive.

To solve this problem, they hired a programmer named Brendan Eich.

His task was ambitious:

Create a scripting language that could run directly inside web browsers.

And he had very little time.

According to the widely shared story in the developer community, Brendan Eich created the first version of JavaScript in just ten days.

The language wasn't originally called JavaScript.

Its journey went through several names:

First Name: Mocha

Initially, the language was named Mocha.

This was simply an internal project name.

Second Name: LiveScript

As development progressed, Netscape renamed it LiveScript.

The idea was to highlight how scripts could make websites "live" and interactive.

Final Name: JavaScript

Later, Netscape renamed the language JavaScript.

At that time, Java was one of the most popular programming languages in the world.

The new name helped attract attention.

However, many beginners still misunderstand one important fact:

Java and JavaScript are completely different languages.

The names are similar.

The technologies are not.

It's a bit like comparing a car and a carpet simply because their names start with the same letters.

-----------------------------------------------------------------------------------------------------

The Browser Wars: When Every Company Wanted Its Own JavaScript

As JavaScript became more popular, competition between browser companies intensified.

Netscape included JavaScript in its browser.

Microsoft noticed the growing popularity of scripting and introduced its own version called JScript inside Internet Explorer.

This created a problem.

Code that worked perfectly in one browser might behave differently in another browser.

Developers became frustrated.

Businesses became frustrated.

Users experienced inconsistent websites.

Something needed to change.


The Birth of ECMAScript

To solve browser compatibility issues, a standards organization called Ecma International stepped in.

Their goal was simple:

Create a common standard that all browsers could follow.

This standard became known as ECMAScript.

Think of ECMAScript as the rulebook.

JavaScript is the actual language implementation that follows those rules.

A simple analogy:

  • ECMAScript = Recipe
  • JavaScript = Actual Dish

Different browsers can create their own implementations, but they all follow the same recipe.

This standardization helped JavaScript grow into the dominant language we know today.


Major JavaScript Versions That Changed Everything

JavaScript didn't become powerful overnight.

It evolved over many years.

ES1 (1997)

The first official standardized version.

This established the foundation for future development.

ES5 (2009)

A major update that introduced several important features and improvements.

Many older websites still contain ES5 code today.

ES6 (2015)

This was the biggest transformation in JavaScript history.

Developers often call it "Modern JavaScript."

ES6 introduced features such as:

  • let and const
  • Arrow functions
  • Classes
  • Template literals
  • Modules
  • Promises

These additions dramatically changed how developers write JavaScript applications today.

Since then, new features have been released regularly through the TC39 committee, which continues to guide the language's future.


What Exactly Is JavaScript?

If someone asked you to explain JavaScript in one sentence, what would you say?

A beginner-friendly definition would be:

JavaScript is a programming language that allows developers to create interactive and dynamic websites.

Without JavaScript, websites would mostly be static.

Buttons wouldn't respond.

Forms wouldn't validate instantly.

Menus wouldn't open smoothly.

Real-time updates wouldn't exist.

In simple terms:

HTML creates the structure.

CSS creates the design.

JavaScript creates the behavior.

Think of building a car.

  • HTML = Car body
  • CSS = Paint and styling
  • JavaScript = Engine

Without the engine, the car may look beautiful, but it won't move.

That's exactly what JavaScript does for websites.


Why JavaScript Became So Popular

One of the biggest reasons behind JavaScript's success is accessibility.

Anyone with a web browser can start learning it.

No complicated setup.

No expensive software.

No special hardware requirements.

Developers love JavaScript because it offers:

  • Fast development
  • Immediate visual feedback
  • Huge community support
  • Cross-platform compatibility
  • Massive job opportunities

Today, JavaScript is no longer limited to browsers.

Developers use it for:

  • Frontend development
  • Backend development (Node.js)
  • Mobile applications
  • Desktop applications
  • Cloud services
  • APIs
  • Game development

Very few programming languages have expanded this far.

And that's one reason why JavaScript remains one of the most valuable skills in modern software development.



Dynamic Typing: One of JavaScript's Most Powerful Features

When beginners start learning programming, one of the first things they usually encounter is data types.

Languages such as Java, C++, and C# often require developers to explicitly define the type of data a variable will store.

For example:

int age = 25;
String name = "Alex";

Before storing data, you must tell the language what type of value will be stored.

JavaScript works differently.

JavaScript is a dynamically typed language.

This means JavaScript automatically determines the data type for you.

For example:

let value = 10;

Initially, JavaScript understands that value contains a number.

Later, you can do this:

value = "Hello World";

Now the same variable contains a string.

You can even do this:

value = [1, 2, 3];

Now it contains an array.

This flexibility makes JavaScript easy to learn and quick to develop with.

However, it also means developers need to be careful because unexpected type changes can sometimes create bugs.


Variables: The Containers of JavaScript

Imagine you're moving into a new house.

You have different boxes for storing clothes, books, electronics, and documents.

Variables work in a similar way.

A variable is simply a container that stores data.

JavaScript provides three main ways to create variables:

  • var
  • let
  • const

Modern JavaScript primarily uses let and const.


Understanding let

The let keyword creates a variable whose value can be changed later.

Example:

let age = 25;

age = 26;

This works perfectly.

Because variables declared with let are designed to allow updates.

Think of it as a whiteboard.

You can erase old content and write new content whenever needed.


Understanding const

The const keyword creates a variable whose reference cannot be reassigned.

Example:

const age = 25;

This is valid.

But:

const age = 25;

age = 30;

Produces an error.

Why?

Because JavaScript protects constant values from reassignment.

Imagine writing something permanently with a marker instead of a pencil.

Once written, it cannot simply be erased.

This is why many developers use const whenever a value should remain unchanged.


A Common Interview Question About Variables

Consider this example:

let value = 10;

function test(value) {
    value = 9;
    console.log(value);
}

test(value);

console.log(value);

Many beginners expect both outputs to become 9.

But the actual result is:

9
10

Why?

Because the function receives a copy of the value.

Changes made inside the function do not affect the original variable outside the function.

This concept becomes extremely important when learning functions and scope.


JavaScript Is Case Sensitive

One of the most common beginner mistakes involves variable naming.

JavaScript treats uppercase and lowercase letters differently.

Example:

let name = "Alex";

let Name = "John";

These are two completely different variables.

JavaScript sees them as separate identifiers.

Think about passwords.

"Password123" and "password123" are not the same.

JavaScript applies similar rules to variable names.


Understanding Undefined and Null

Many beginners confuse undefined and null because both represent missing values.

However, they are not identical.


What Is Undefined?

Undefined means a value has not been assigned yet.

Example:

let username;

console.log(username);

Output:

undefined

JavaScript is essentially saying:

"I know this variable exists, but nobody has given it a value yet."

Think of an empty box waiting to be filled.


What Is Null?

Null is intentionally assigned by a developer.

Example:

let user = null;

Here, you're explicitly saying:

"This variable currently has no value."

A useful analogy:

Undefined:
You forgot to place anything inside the box.

Null:
You deliberately placed a note inside the box saying:

"There is nothing here."


Why Does typeof Null Return Object?

One of JavaScript's most famous quirks is:

typeof null

Output:

object

This surprises almost every beginner.

Historically, this behavior originated from an old bug in JavaScript's early implementation.

By the time developers realized it was technically incorrect, too many websites relied on it.

Changing the behavior would have broken existing applications.

So the bug became part of JavaScript history.

Sometimes software development works that way.


Strings: Working With Text

Strings are one of the most commonly used data types in JavaScript.

A string represents textual data.

Examples:

let name = "Alex";

let city = "Delhi";

let course = "JavaScript";

Every character inside a string has a position called an index.

JavaScript starts counting from zero.

Example:

let language = "JavaScript";

Indexes:

J = 0
a = 1
v = 2
a = 3
S = 4
c = 5
r = 6
i = 7
p = 8
t = 9

This is known as zero-based indexing.


---------------------------------------------------------------------------------------------

Useful String Methods Every Developer Should Know

Strings come with built-in methods that make text manipulation easy.


trim()

Removes unnecessary spaces.

let name = "   Alex   ";

console.log(name.trim());

Output:

Alex

Useful when processing user input.


toUpperCase()

Converts text into uppercase.

let city = "delhi";

console.log(city.toUpperCase());

Output:

DELHI

toLowerCase()

Converts text into lowercase.

let city = "DELHI";

console.log(city.toLowerCase());

Output:

delhi

slice()

Extracts a portion of a string.

let course = "JavaScript";

console.log(course.slice(0,4));

Output:

Java

indexOf()

Finds the position of a character or word.

let language = "JavaScript";

console.log(language.indexOf("S"));

Output:

4

These methods are used daily in real-world development projects.

Whether you're validating forms, building search features, or processing user input, string methods become indispensable.


Type Conversion: Turning Strings Into Numbers

Imagine receiving user input from a form.

Everything entered by the user arrives as text.

But what if you need to perform calculations?

You must convert the string into a number.

Example:

let age = "25";

Currently, age is a string.

You can convert it using:

let age = "25";

console.log(typeof (+age));

Output:

number

The plus sign tells JavaScript:

"Convert this text into a numeric value."

This simple trick appears frequently in professional projects.


Converting Numbers Into Strings

The reverse process is equally important.

Example:

let score = 100;

score = score + "";

Now:

typeof score

returns:

string

This technique is often used when displaying values to users.


Real Developer Tip

One reason JavaScript became so popular is because it feels forgiving.

You can convert types easily.

You can create variables quickly.

You can build working applications without writing a huge amount of code.

However, experienced developers learn an important lesson:

Just because JavaScript allows something doesn't always mean it's the best practice.

Understanding data types, variables, and type conversion properly is one of the foundations that separates beginner developers from professional developers.

---------------------------------------------------------------------------------------------

BigInt: When Normal Numbers Are Not Enough

Most of the time, JavaScript handles numbers without any problems.

Whether you're calculating shopping cart totals, student marks, salaries, or distances, the standard Number data type works perfectly.

However, there is a hidden limitation many beginners don't know about.

JavaScript can safely handle integers only up to:

9007199254740991

This value is also known as:

Number.MAX_SAFE_INTEGER

What happens if you go beyond this limit?

The calculations may become inaccurate.

Imagine working with:

  • Banking systems
  • Scientific calculations
  • Cryptocurrency applications
  • Large databases

In such situations, even a tiny numerical error can create major problems.

This is where BigInt comes in.


--------------------------------------------------------------------------------

Creating a BigInt

The easiest way is to add n at the end of a number.

let amount = 9816543219865252772n;

JavaScript now treats this value as a BigInt.

You can also create it using:

let amount = BigInt(9816543219865252772);

One important limitation:

123.45n

This is invalid.

BigInt only supports whole numbers.

No decimal values allowed.

Think of BigInt as a special storage room designed specifically for extremely large numbers.

Most developers won't need it every day, but when dealing with huge values, it's incredibly useful.


Objects: The Heart of JavaScript

If variables are containers, objects are entire storage cabinets.

Real-world things have multiple properties.

For example, imagine a student:

  • Name
  • Age
  • Course
  • City

Instead of creating separate variables, JavaScript allows us to group related information together.

Example:

const student = {
    name: "Alex",
    age: 22,
    city: "Delhi"
};

This structure is called an object.

Objects are everywhere in JavaScript.

In fact, modern JavaScript development revolves heavily around objects.


Methods: Functions Living Inside Objects

An object can also contain functions.

When a function exists inside an object, we call it a method.

Example:

const person = {
    name: "Alex",

    about: function() {
        console.log(`My name is ${this.name}`);
    }
};

person.about();

Output:

My name is Alex

Notice the word:

this

The this keyword refers to the current object.

Think of it as the object saying:

"Look at my own data."

Methods help objects perform actions, not just store information.


Prototypes: JavaScript's Secret Superpower

At first, prototypes can feel confusing.

But once understood, they become one of JavaScript's most powerful features.

Let's imagine a school.

There are 1,000 students.

Every student should have access to a method called:

greet()

You could add the same function individually to every student.

But that would waste memory.

Instead, JavaScript allows all students to share a single method through prototypes.

Example:

function Person(name) {
    this.name = name;
}

Person.prototype.greet = function() {
    console.log(`Hi, I'm ${this.name}`);
};

Now:

const user = new Person("John");

user.greet();

Output:

Hi, I'm John

The greet method exists only once.

All objects created from Person can use it.

This makes JavaScript more memory efficient.


Understanding the new Keyword

The new keyword looks simple.

But it performs several operations behind the scenes.

Example:

const user = new Person("Alex");

Behind the scenes, JavaScript:

Step 1

Creates a new empty object.

{}

Step 2

Connects the object to the prototype.

Step 3

Assigns this to the new object.

Step 4

Runs the constructor function.

Step 5

Returns the final object.

It's like a factory machine.

You provide raw material.

The machine builds a complete product and hands it back to you.


Parameter Destructuring: Cleaner Function Arguments

Imagine receiving an object containing multiple properties.

Example:

const user = {
    name: "Alex",
    age: 20,
    city: "Delhi"
};

Normally:

function showData(obj) {
    console.log(obj.name);
    console.log(obj.age);
}

JavaScript offers a cleaner approach called destructuring.

Example:

function showData({name, age}) {
    console.log(name);
    console.log(age);
}

This improves readability significantly.

Modern JavaScript projects use destructuring extensively.


Sets: Collections Without Duplicates

Suppose you're creating an attendance system.

Student names should appear only once.

You don't want duplicates.

This is where Sets become useful.

Example:

let students = new Set();

students.add("Alex");
students.add("Alex");
students.add("John");

Result:

Set(2)

Only unique values are stored.

Common methods include:

add()
has()
delete()
clear()
size

Sets are frequently used when duplicate values must be avoided.


Synchronous Programming: The Natural Behavior of JavaScript

JavaScript executes code line by line.

Example:

console.log("Start");

console.log("Middle");

console.log("End");

Output:

Start
Middle
End

JavaScript waits for each statement to finish before moving to the next one.

This behavior is called synchronous programming.

Think of standing in a queue at a bank.

The next customer cannot proceed until the current customer finishes.


The Problem With Synchronous Code

Imagine downloading a huge file.

The operation takes 10 seconds.

If JavaScript waited for everything synchronously, the entire webpage would freeze.

Users would become frustrated.

To solve this issue, JavaScript introduced asynchronous programming.

------------------------------------------------------------------------------

Asynchronous Programming: Working Smarter

Asynchronous programming allows JavaScript to continue working while waiting for time-consuming operations.

Example:

console.log("Start");

setTimeout(() => {
    console.log("Hello");
}, 2000);

console.log("End");

Output:

Start
End
Hello

Notice something interesting.

Even though setTimeout appears in the middle, JavaScript doesn't wait.

Instead:

  • Timer is handed to the browser.
  • JavaScript continues executing.
  • Callback executes later.

This creates faster, smoother applications.


Callbacks: The Foundation of Async JavaScript

A callback is simply a function passed into another function.

Example:

function task(callback) {

    console.log("Task Completed");

    callback();
}

task(() => {
    console.log("Next Task");
});

Output:

Task Completed
Next Task

Think of callbacks as instructions.

You're telling JavaScript:

"After finishing this work, execute that function."

Callbacks became the foundation of asynchronous programming before Promises and Async/Await arrived.


Why Learning These Concepts Matters

Many beginners rush toward frameworks like:

  • React
  • Next.js
  • Node.js
  • Angular
  • Vue

But experienced developers know something important.

Frameworks change.

JavaScript fundamentals remain.

Understanding:

  • Objects
  • Methods
  • Prototypes
  • Destructuring
  • Sets
  • Callbacks
  • Synchronous vs Asynchronous behavior

will help you understand every modern JavaScript framework much faster.

A strong foundation is what transforms a beginner who copies code into a developer who truly understands it.


Event Loop: The Concept That Confuses Almost Every JavaScript Beginner

If you ask experienced developers which JavaScript topic confused them the most when they were learning, many will give the same answer:

The Event Loop.

At first glance, JavaScript seems simple.

It executes code line by line.

But then you encounter code like this:

console.log("Start");

setTimeout(() => {
  console.log("Timeout");
}, 0);

console.log("End");

Most beginners expect:

Start
Timeout
End

But the actual output is:

Start
End
Timeout

Why?

The answer lies in understanding how JavaScript actually works behind the scenes.


JavaScript Is Single Threaded

One of the most common interview questions is:

"Is JavaScript single-threaded?"

The answer is:

Yes.

JavaScript can execute only one task at a time.

Imagine a restaurant with only one chef.

The chef can prepare only one dish at a time.

Similarly, JavaScript can execute only one piece of code at a time.

This might sound like a limitation.

But surprisingly, JavaScript manages to build highly interactive applications despite being single-threaded.

How?

The answer is the Event Loop.


Understanding the Call Stack

The Call Stack is where JavaScript executes code.

Think of it as a stack of plates.

The last plate placed on top is removed first.

Example:

console.log("Hello");

JavaScript places this task into the Call Stack.

Executes it.

Then removes it.

Simple.

Now consider:

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

greet();

Here's what happens:

Step 1

Global Execution Context enters the stack.

Step 2

greet() is called.

Step 3

A new Function Execution Context enters the stack.

Step 4

console.log executes.

Step 5

Function context leaves the stack.

Step 6

Control returns to Global Execution Context.

This entire process happens incredibly fast.

Usually in milliseconds.


What Happens When JavaScript Encounters setTimeout?

Consider:

console.log("1");

setTimeout(() => {
    console.log("2");
}, 1000);

console.log("3");

Output:

1
3
2

This surprises many beginners.

Let's break it down step by step.


Step 1: Call Stack Executes "1"

console.log("1");

Output:

1

Stack becomes empty again.


Step 2: JavaScript Sees setTimeout

JavaScript itself cannot handle timers.

Instead, it hands this task over to Browser APIs.

Think of Browser APIs as assistants.

JavaScript says:

"Please watch this timer for me."

Browser starts the timer.

Meanwhile JavaScript continues working.


Step 3: Execute "3"

console.log("3");

Output:

3

JavaScript doesn't wait.

It moves ahead immediately.


Step 4: Timer Completes

After one second:

() => console.log("2")

moves into the Callback Queue.


Step 5: Event Loop Steps In

The Event Loop constantly checks:

"Is the Call Stack empty?"

If yes:

Take the next task from the Callback Queue and execute it.

Output:

2

Final result:

1
3
2

This entire mechanism is what makes JavaScript asynchronous.


The Three Important Components

To understand async JavaScript, remember these three pieces.


1. Call Stack

Where code executes.


2. Web APIs

Provided by the browser.

Examples:

  • setTimeout

  • setInterval

  • DOM Events

  • Fetch API

These tasks execute outside JavaScript's main thread.


3. Event Loop

Traffic controller.

Moves tasks from queues into the Call Stack whenever possible.

Without the Event Loop, modern web applications would not exist.


Callback Queue (Task Queue)

Whenever an asynchronous task finishes:

The callback moves into the Callback Queue.

Example:

setTimeout(() => {
    console.log("Hello");
}, 1000);

After one second:

() => {
   console.log("Hello");
}

waits inside the Callback Queue.

It cannot execute immediately.

It must wait for the Event Loop to move it into the Call Stack.


Microtask Queue: The VIP Queue

Most beginners learn about the Callback Queue.

Fewer learn about the Microtask Queue.

And this creates confusion.

JavaScript actually has multiple queues.

The Microtask Queue gets higher priority.

It stores:

  • Promise.then()

  • Promise.catch()

  • Promise.finally()

  • process.nextTick() (Node.js)


Example

console.log("Start");

setTimeout(() => {
    console.log("Timeout");
}, 0);

Promise.resolve().then(() => {
    console.log("Promise");
});

console.log("End");

What do you think happens?

Output:

Start
End
Promise
Timeout

Why?

Because Microtasks execute before Callback Queue tasks.

Think of it like an airport.

Regular passengers wait in a normal line.

VIP passengers use a priority lane.

Promises use the priority lane.


Execution Context: JavaScript's Workspace

Every piece of JavaScript code executes inside something called an Execution Context.

You can think of it as JavaScript's workspace.

Whenever JavaScript starts executing code, it creates an environment containing:

  • Variables

  • Functions

  • Scope information

  • this keyword information


Global Execution Context (GEC)

When a JavaScript file starts running:

The first thing created is the Global Execution Context.

Example:

console.log("Start");

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

greet();

console.log("End");

Execution order:

  1. Global Execution Context created.

  2. Start prints.

  3. greet() called.

  4. Function Execution Context created.

  5. Hello prints.

  6. Function context destroyed.

  7. End prints.

Output:

Start
Hello
End

Function Execution Context (FEC)

Every time a function runs:

JavaScript creates a new execution context.

Example:

function add(a, b) {
   return a + b;
}

add(5, 10);

A separate execution context is created specifically for the add() function.

Once execution finishes:

That context is removed.

This keeps memory usage efficient.


Why Promises Were Introduced

Before Promises existed, developers relied heavily on callbacks.

Example:

loginUser(() => {

   getProfile(() => {

      loadSettings(() => {

          showDashboard();

      });

   });

});

This structure becomes difficult to read.

Developers call it:

Callback Hell

Because the code drifts toward the right side of the screen.

Promises were introduced to solve this problem.


Async/Await: Making Async Code Look Synchronous

Modern JavaScript introduced Async/Await.

Example:

async function fetchData() {

    let result = await fetch("/api/users");

    console.log(result);
}

This code is easier to read.

Easier to debug.

Easier to maintain.

Behind the scenes:

Promises still exist.

Async/Await simply provides cleaner syntax.


Most Common JavaScript Interview Questions
Why Is JavaScript Single Threaded?

Because it was originally designed to safely interact with the DOM.

Multiple threads changing the same webpage simultaneously would create conflicts.


What Is Event Loop?

A mechanism that continuously checks the Call Stack and moves tasks from queues for execution.


Difference Between Microtask and Macrotask?

Microtask:

  • Promise.then

  • Promise.catch

  • process.nextTick

Macrotask:

  • setTimeout

  • setInterval

  • DOM events

Microtasks always execute first.


What Is Execution Context?

The environment where JavaScript code executes.


What Is Call Stack?

A structure where JavaScript keeps track of function execution.


Final Thoughts

At first, JavaScript may seem simple.

Variables.

Functions.

Objects.

Strings.

But underneath the surface lies a sophisticated engine that powers some of the world's largest applications.

Understanding:

  • Call Stack

  • Event Loop

  • Execution Context

  • Callback Queue

  • Microtask Queue

  • Promises

  • Async/Await

is what separates a beginner from a professional JavaScript developer.

Frameworks like React, Next.js, Angular, and Node.js all rely heavily on these concepts.

If you truly understand these fundamentals, learning advanced technologies becomes dramatically easier.

And that is why mastering JavaScript fundamentals is one of the best investments any developer can make.

Post a Comment

0 Comments