Classical Vs prototypal inheritance

前端 未结 3 1958
广开言路
广开言路 2020-11-30 01:43

After reading about both, I just have curiosity, how programming community uses this? In what situation which?

3条回答
  •  时光说笑
    2020-11-30 01:48

    Prototype-based inheritance is more flexible. Any existing object can become a class from which additional objects will be spawned. This is handy where your objects offer several sets of services and/or they undergo a lot of state transformation before your program arrives at the point where the inheritance is needed.

    A broad-spectrum discussion of modeling approaches is available here: http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html

提交回复
热议问题