samedi 28 février 2015

What can the JavaScript prototype system do beyond mimicking a classical class system?


The prototype system looks much more flexible than the traditional class system, but people seem to feel content with the so-called "best practices", which mimic the traditional class system:



function foo() {
// define instance properties here
}

foo.prototype.method = //define instance method here

new foo()


There must be other things that a prototypical system can do with all the flexibility.


Are there uses for a prototypical system outside of mimicking classes? What kinds of things can prototypes do which classes cannot, or are there none?





Aucun commentaire:

Enregistrer un commentaire