Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8965395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:47:34+00:00 2026-06-15T16:47:34+00:00

Whats the difference between Employee.prototype = Object.create(Person.prototype); and _.extend(Employee.prototype, Person.prototype); Both give similar results

  • 0

Whats the difference between

Employee.prototype = Object.create(Person.prototype);

and

_.extend(Employee.prototype, Person.prototype);

Both give similar results (output), but the underscore method seems to add the Person.prototype to the Employee.constructor.prototype, and quite abit extra stuff here and there, why?

pure JS

enter image description here

underscoreJS

enter image description here

A nice side effect of _.extend is I can easily do multiple inheritance: seems like it doesnt make the prototype chain longer too …

_.extend(Employee.prototype, Person.prototype);
_.extend(Employee.prototype, {
    doSomething: function() {
        return "hi ...";
    }
});

But …

enter image description here

Why is there 2 sayHi and doSomething functions? (actually its the same when I just do 1 extend).

http://jsfiddle.net/VMqSy/1/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:47:35+00:00Added an answer on June 15, 2026 at 4:47 pm

    With Employee.prototype = Object.create(Person.prototype); you are completely replacing the Employee.prototype.

    But with _.extend(Employee.prototype, Person.prototype); you are adding the Person.prototype on top of the Employee.prototype.

    For example,

    var a = {var1:1, var2:2};
    var b = {var2:4, var3:3};
    console.log(_.extend(a, b)); // {var1:1, var2:4, var3:3}
    

    As you see, a it’s not completely replaced by b, it’s just extended by the properties defined in b.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering whats the difference between store() and add()? They seem very similar,
a=[1,2,3] b=[4,5,6] c=[] d=[] Whats the difference between these two statements? c[:]=a d=b[:] But
Whats the difference between: @interface SomeClass : NSObject { NSObject *something; } and @interface
Whats the difference between Cast & Convert in C# 2008?
Whats the difference between SELECT DISTINCT field1 FROM table1 cd JOIN table2 ON cd.Company
Whats the difference between Url.Action and Html.RenderActionLink in asp.net mvc?
Whats the difference between using a LEFT OUTER JOIN , rather than a sub-query
In objective-c whats the difference between using a . and using ->? I've used
In javascript whats the difference between undefined == variable and variable == undefined are
I would like to ask whats the difference between for row in session.Query(Model1): pass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.