← Back to list

JStra: Why Everything is an Object?

when the web was kinda dull with just HTML. Then, Brendan Eich came up with JavaScript in just 10 days! Inspired by Java

Abutayar Shaikh · 2024-12-31 18:32 · 8 claps · 3.7 min read
#javascript #javascript-history #object-oriented #magic #inspiration
Open on Medium ↗
Wiki topics: 🌐 · Web Development ✨ · Lifestyle · General

JStra: Why Everything is an Object?

Hi there, coding pals! Today, let’s talk about JavaScript, the cool tool that makes web pages lively. We’ll dive into why JavaScript likes to be called “object-oriented” and how it changed web development. Ready for the ride?

Chapter 1: How JavaScript Came to Be

Imagine the mid-1990s, when the web was dull with HTML. Then, Brendan Eich came up with JavaScript in just 10 days! Inspired by Java, it joined hands with the Document Object Model (DOM). Objects took the spotlight, becoming the go-to for playing with web page stuff.

Chapter 2: Simple Things Acting Fancy

In JavaScript, even basic stuff, or “primitives,” can act like objects.

Douglas Crockford once said, “JavaScript is the only language that I’m aware of that people feel they don’t need to learn before they start using it.

A simple string turns into a mini-object, doing a fancy trick with the toUpperCase thing.

Chapter 3: Functions — Your Helpful Buddies

In JavaScript, functions are like your buddies, always ready to do something.

Kyle Simpson once said, “JavaScript is the language that I love the most, even when I hate it.

Functions can be passed around, given a nickname (assigned to variables), and even become friends with other objects. Check this out:

A function, like greet, shares its charm with a variable, now called sayHello, giving a warm greeting to our buddy John.

Chapter 4: Inheriting Skills — A Bit Fancy

In JavaScript, objects learn cool stuff through something called prototypal inheritance.

Eric Elliott says, “JavaScript is the most misunderstood language of our time.

Objects break free from the usual way of learning and inherit skills through prototypes. Watch this:

Meet our friend, a cat born into the animal family, learning to make a sound through this special magic.

Chapter 5: Everything’s an Object? The Object-Oriented Vibe

One fascinating aspect of JavaScript is its object-oriented nature, and it’s not just limited to what we typically think of as objects. Almost everything behaves like an object in JavaScript, thanks to its prototype-based model.

When we say “everything’s an object” we mean that even primitive types, like strings, numbers, and booleans, can act like objects, as shown in Chapter 2. This is possible because JavaScript has a feature called “autoboxing” where it temporarily wraps primitive values in objects to allow them to use methods and properties.

Here, the primitive number 42 temporarily acts like an object, using the toString method. This object-like behavior extends the capabilities of basic types, making them more versatile in the JavaScript world.

Understanding this object-oriented vibe is crucial for harnessing the full power of JavaScript. It allows developers to treat different data types consistently, making the language more flexible and expressive.

Chapter 6: The Prototype Chain — Linking Objects

JavaScript’s object-oriented magic goes deeper with the concept of the prototype chain. Each object in JavaScript has a prototype, which can be another object. This forms a chain, allowing objects to inherit properties and methods from their prototypes.

Let’s delve into an example:

In this example, the Car constructor inherits properties and methods from the Vehicle constructor through the prototype chain. This way, JavaScript mimics classical inheritance elegantly and dynamically.

Chapter 7: Object Literals — Shaping the World

JavaScript’s object-oriented features also shine through object literals, providing a concise way to create objects on the fly. This versatility allows developers to shape and structure data with ease.

Consider this object literal:

Here, we’ve created an object person with properties and a method using a simple and expressive syntax. Object literals play a crucial role in the everyday coding experience of JavaScript developers.

In summary, JavaScript’s swift evolution since the mid-1990s, driven by Brendan Eich’s creation in just 10 days, has revolutionized web development. The language’s object-oriented nature, evident in the temporary object-like behavior of primitives, and features like functions and prototypal inheritance, make it a dynamic and powerful tool for building interactive applications.

What do you think about JavaScript and its journey? Share your thoughts or any coding stories in the comments. Let’s chat and explore JavaScript’s cool world together!

Originally published at https://www.linkedin.com.


메타데이터
post_id
5ecc22e216b0
slug
jstra-why-everything-is-an-object-5ecc22e216b0
url
https://medium.com/@abutayar/jstra-why-everything-is-an-object-5ecc22e216b0
canonical_url
https://medium.com/@abutayar/jstra-why-everything-is-an-object-5ecc22e216b0
author_url
https://medium.com/@abutayar
status
ok
fetched_at
2026-08-09 11:33:16