Avoid class like inheritance using the new function. Especially for Java developers this approach might cause confusion and is error prone because inheritance using prototypes does not always behaves like some class minded developer might think (e.g. overloading of properties, prototype vs. local properties/methods). As inheritance is mainly used for the reuse of application logic, JavaScript offers other concepts for reuse that fit better with the dynamic aspect of the language:
- Copying of properties/methods,
- Mix-Ins or
- Borrowing Methods
Keine Kommentare:
Kommentar veröffentlichen