J
JavaScript Objects & Prototypes
Explore object creation, property access, methods, prototypes, and the prototype chain interactively.
Programming
v1.0.0
26 uses
J
JavaScript Objects & Prototypes
Esc
or
Ctrl+Shift+F
to exit
Step 1: What are Objects?
In JavaScript, an object is a collection of key-value pairs. Each pair is called a property. When a property's value is a function, it is called a method.
Objects are the most fundamental data structure in JavaScript — arrays, functions, dates, and even regular expressions are all objects under the hood.
Object Literal: person
Key
Value
name
"Alice" (string)age
30 (number)greet
function() (method)Key terms:
- Property — a key-value pair stored in an object
- Key — the name (always a string or Symbol) that identifies a property
- Value — the data stored under a key (any type: string, number, array, object, function, etc.)
- Method — a property whose value is a function
- Dot notation —
person.name— the most common way to access properties - Bracket notation —
person["name"]— required when keys have spaces or are dynamic
// Creating an object with an object literal
const person = {
name: "Alice",
age: 30,
greet: function() {
return "Hi, I'm " + this.name;
}
};
// Accessing properties
person.name; // "Alice" (dot notation)
person["age"]; // 30 (bracket notation)
person.greet(); // "Hi, I'm Alice"
About This Lab
Objects are the building blocks of JavaScript. In this lab, you'll learn to create objects with literals and constructors, access and modify properties, understand methods and 'this', explore the prototype chain, and use Object.create and classes — all with live code editors and visual diagrams.
How It Works
- 1 Read each step's explanation of object concepts
- 2 Write code in the interactive editors
- 3 Inspect objects in the visual property inspector
- 4 Trace the prototype chain
- 5 Complete the quiz to test your understanding
More Labs in Programming
J
JavaScript Promises & Async
ProgrammingMaster asynchronous JavaScript — callbacks, Promises, async/await, and error handling with visual timelines.
P
Python Basics
ProgrammingWrite your first Python code — learn variables, data types, conditionals, and loops interactively.
A
Array Methods in JavaScript
ProgrammingMaster map, filter, reduce, and more — transform arrays with live code exercises and visual diagrams.