01 / 04
One blueprint, many objects
INPUT · Slides
A class is a blueprint for one shape
02 / 04
Write the blueprint first
That way is a class. Write class Name { } and you have one blueprint saying this is the shape of thing I make.
We will be filling the inside in from here, so an empty { } is fine for now. Even that much is not an error.
class Card {}console.log("Card blueprint");Result
Card blueprint
03 / 04
The name starts with a capital
It is the convention that a class name starts with a capital. So that card the container variable and Card the blueprint can be told apart by eye.
Make the name what you call one of them. Even for a blueprint that turns out a whole pile of cards, it is Card, not Cards.
class Card {}class Monster {}console.log("two blueprints made");Result
two blueprints made
04 / 04
A blueprint is not yet a real one
Stare at a waffle iron all you like and no waffle comes out. A class is the same: writing one does not bring a single piece of real data into being.
The steps for making a real one from the mould come next lesson.
This round is practice at writing blueprints. Since you cannot make real ones yet, show data of that shape as a hand-written object. Off you go.