Blueprint to Object
Students learn that a class is a blueprint and an object is one thing made from that blueprint.
Blueprint → Object
A class is the blueprint; an object is the thing built from it. The blueprint for a Creature says "every creature has a name and a sound, and knows how to speak." Then new builds Pixel — a real creature you can talk to.
-
1
The blueprint never beeps
class Creature { ... }is just a plan — it describes names, sounds, and aspeak()action, but no creature exists yet. Blueprints don't make noise; buildings do. -
2
newbuilds the real thinglet pixel = new Creature("Pixel", "beep");runs the constructor and hands you an actual object. Nowpixel.speak()makes a real creature say a real beep. -
3
Try it
Stamp out a second creature —
new Creature("Echo", "boop")— and make both speak. One blueprint, many creatures, each with its own name and sound.
Make one object from a blueprint.
class Creature {
constructor(name, sound) {
this.name = name;
this.sound = sound;
}
speak() {
say(this.name + " says " + this.sound);
}
}
let pixel = new Creature("Pixel", "beep");
pixel.speak();
Program result
- Run your code to see output.
Type real JavaScript, then run it.
You made one object from a class blueprint and called its method.
Open OOP Builder