- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In JavaScript inheritance how to differentiate Object.create vs new?
In the first example, you are just inheriting amitBaseClass prototype.
function SomeClass() { } SomeClass.prototype = Object.create(amitBaseClass.prototype);
In the second example, you are executing the constructor function. An instance of amitBaseClass is created and you are inheriting the who complete amitBaseClass object.
function SomeClass () { } SomeClass.prototype = new amitBaseClass ();
So, both are doing separate work.
- Related Articles
- Inheritance in C++ vs Java
- Composition vs inheritance in React.js
- Inheritance vs Composition in C#
- Delegation vs Inheritance in C#
- Virtual vs Sealed vs New vs Abstract in C#
- Explain Inheritance vs Instantiation for Python classes.
- Multiple inheritance in JavaScript
- When to Use an Alias vs Script vs a New Function in Bash
- malloc() vs new() in C/C++
- Inheritance in JavaScript with example
- How to differentiate between Manual and Automated Animation in JavaScript?
- How to new line string - JavaScript?
- Differentiate between 32-Bit vs. 64-Bit Operating System.
- How to open link in a new window - JavaScript?
- How to provide new line in JavaScript alert box?

Advertisements