For sure. The modern JavaScript syntax defines the class and methods all at once, so that's a single step.
Once that's defined, other parts of the program can create instances of the class and use them in the program execution. That is, creating and using objects happens after all the parts (functions, classes) are defined.
In relatively static languages like Java, all the definitions
happen first (during compilation when .java
files are turned into .class files), and the run-time
comes after.
JavaScript can be more dynamic than that, though in practice it often works similarly.
Coffeerun is like that, and we will be using JS in the static mode: define first, executesecond.
Interesting!
In video game development, a prefab (short for prefabricated object) is a reusable game object template that you can place into a scene multiple times. Think of it as a saved blueprint of an object that includes its components, properties, and sometimes child objects.
So, yes, I think there's a lot in common between the two ideas.
In the case of OOP, the prototypes holds the methods and other properties shared by all the objects of a particular class.
Good question. I should discuss APIs more in the reading.
I've just added API. Let's look at it together.
It looks like I should discard that question. I'll ask LTS about how to do that.