Inheritance vs Composition in JavaScriptby@serhiirubets
4,621 reads

Inheritance vs Composition in JavaScript

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Inheritance is one of the core concepts of object-oriented programming, that helps us, developers to avoid code duplication. The main idea is that we create a base class, which contains logic, that will be reused by our subclasses. Unlike inheritance, the composition uses a **has-a** relationship. We collect different pieces of functionality together. For example, “***Form***” is an ‘***Element***’ and ‘*Element’ is a ‘**Element*’

Company Mentioned

Mention Thumbnail
featured image - Inheritance vs Composition in JavaScript
Serhii Rubets HackerNoon profile picture

@serhiirubets

Serhii Rubets

I'm a Fullstack JS engineer with 10 years of experience. Also, I'm a mentor, teacher, and author of front-end courses.


Receive Stories from @serhiirubets

react to story with heart
Serhii Rubets HackerNoon profile picture
by Serhii Rubets @serhiirubets.I'm a Fullstack JS engineer with 10 years of experience. Also, I'm a mentor, teacher, and author of front-end courses.
Read my stories

RELATED STORIES

L O A D I N G
. . . comments & more!