3 ms·
Go for it. In a nutshell: An object is a unit of code and data that can be treated as a distinct entity. Classes and prototypes are both way to make objects. W
by jashkenas 15y ago
Go for it. In a nutshell:
An object is a unit of code and data that can be treated as a distinct entity. Classes and prototypes are both way to make objects. With a prototype, you start with an actual object as an example, and make more objects just like it. With a class, you start with the abstract set of properties that describe a type of object, and make more objects from that blueprint.
Think of it as the Platonic ideal of a thing (the class), versus the canonical example of a thing (the prototype).
To get specific: The idea of Bicycle, versus my blue bike with red streamers. Both can be used to make more bikes, in JavaScript.
newBike = new Bicycle
newBike = Object.create(myBlueBike)
- nuclearsandwich 15y agoAwesome. Thanks for that. I've always enjoyed the link between Platonic forms and object Classes. ahhhphilosophy.jpg