Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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)


Awesome. Thanks for that. I've always enjoyed the link between Platonic forms and object Classes.

ahhhphilosophy.jpg




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: