Good Example of JavaScript's Prototype-Based Inheritance

后端 未结 11 792
情书的邮戳
情书的邮戳 2020-11-29 15:52

I have been programming with OOP languages for over 10 years but I\'m learning JavaScript now and it\'s the first time I\'ve encountered prototype-based inheritance. I tend

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 16:22

    Douglas Crockford has a nice page on JavaScript Prototypal Inheritance:

    Five years ago I wrote Classical Inheritance in JavaScript. It showed that JavaScript is a class-free, prototypal language, and that it has sufficient expressive power to simulate a classical system. My programming style has evolved since then, as any good programmer's should. I have learned to fully embrace prototypalism, and have liberated myself from the confines of the classical model.

    Dean Edward's Base.js, Mootools's Class or John Resig's Simple Inheritance works are ways to do classical inheritance in JavaScript.

提交回复
热议问题