This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

The Joy of Javascript: prototype inheritance vs classical inheritance

 
Greenhorn
Posts: 26
IntelliJ IDE Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Luis,
what is the difference between prototype inheritance and classical inheritance? Can you describe it's pros and cons?

Thanks!
 
Ranch Hand
Posts: 73
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Coming from java background I don't have much idea about the various types of inheritance in javascript

I just chanced upon this blog and which has a very interesting take on the javascript inheritance types

webpage


Class Inheritance: instances inherit from classes (like a blueprint — a description of the class), and create sub-class relationships: hierarchical class taxonomies. Instances are typically instantiated via constructor functions with the new keyword. Class inheritance may or may not use the class keyword from ES6.

Prototypal Inheritance: instances inherit directly from other objects. Instances are typically instantiated via factory functions or Object.create(). Instances may be composed of many different objects, allowing for easy selective inheritance.

Good to hear:

Classes: create tight coupling or hierarchies/taxonomies.
Prototypes: mentions of concatenative inheritance, prototype delegation, functional inheritance, object composition.


 
Marshal
Posts: 65085
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

satya Priya Sundar wrote:. . . I just chanced upon this blog

Well done finding that blog; have a cow

I think, that blog page wrote:. . .
Prototypes: mentions of concatenative inheritance, prototype delegation, functional inheritance, object composition.

Did the blog say what those things mean?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!