What are patterns you could use with prototype inheritance that you cannot with class?

后端 未结 4 1473
长发绾君心
长发绾君心 2021-02-05 12:37

Everyone seems to generally agree that prototype inheritance is simpler and more flexible than class inheritance. What I have not seen in the literature that I\'ve read is very

4条回答
  •  我在风中等你
    2021-02-05 13:03

    One difference (perhaps at least conceptually) is that class inheritance implies that the child IS-A type of the parent. Prototype inheritance makes no such implication; a mammal is a prototype for a cat (the Merriam-Webster definition says this means it's a "pattern for"), but nothing else. A cat is free remove/add/change behaviors as it sees fit.

提交回复
热议问题