Skip to main content

Command Palette

Search for a command to run...

Objects, Constructors & __proto__ — Day 29

Published
2 min read
Objects, Constructors & __proto__ — Day 29

Today’s session at Cudose Creative Agency was a deep dive into Objects — how they’re made, how they inherit, and how constructors and prototypes shape behavior. Objects are everywhere in JS, and understanding them properly changes how you design apps.

---

🔥 What We Covered Today

🔹 Object Literals

The simplest and most common way to create objects.

const user = {

name: "Jordan",

age: 22,

role: "Frontend Developer"

};

Easy to read, great for grouping related data.

---

🔹 Object Constructor (new Object() / Constructor Functions)

Creating objects using constructors and the new keyword.

const person = new Object();

person.name = "Damilola";

person.level = "Intern";

Constructor functions (PascalCase) produce instances:

function User(name) {

this.name = name;

}

const u1 = new User("Jordan");

---

🔹 Object.create() — Prototype-based creation

Create an object with a specified prototype.

const base = { greet() { console.log("Hi!"); } };

const admin = Object.create(base);

admin.role = "Admin";

Powerful for inheritance without constructors.

---

🔹 Functions vs Constructors

Regular functions return values; constructor functions (used with new) create instances and bind this to the new object.

function normal() { return "hi"; }

function Person(name) {

this.name = name;

}

const p = new Person("Ayo");

Constructors: use PascalCase, create instances, this refers to the instance.

---

🔹 __proto__ & Prototype Chain

Every object links to a prototype — the object it inherits from.

__proto__ (or Object.getPrototypeOf(obj)) points to that prototype.

Methods/properties not found on an object are looked up the prototype chain.

Understanding prototypes explains shared methods, lookups, and how inheritance works in JS.

---

🧠 Key Takeaways

Object literals are simple and common.

Constructors create instances; Object.create() gives explicit prototype control.

__proto__ is the hidden link that enables inheritance.

Knowing these patterns helps you design reusable and memory-efficient code.

---

🚀 Final Thoughts

Objects are the backbone of JavaScript apps. Once you understand constructors and the prototype chain, you stop fighting confusing behavior and start writing predictable, reusable code. This was a pivotal day in the internship — things start to click.