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

  • SEARCH
  • Home
  • 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 7902597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:32:31+00:00 2026-06-03T09:32:31+00:00

In backbone.js under the inherits method, the authors does this: var ctor = function()

  • 0

In backbone.js under the inherits method, the authors does this:

var ctor = function() {};
// some other code ...

var child;
// some other code ...
ctor.prototype = parent.prototype;
child.prototype = new ctor();

The above as I understand it is to allow the new object to inherit the prototypical chain of the parent. I’m trying to wrap my head around this, but in practice, is there a difference between the above and assigning the prototype directly?

child.prototype = parent.prototype

I understand that there exists this [[prototype]] object that cannot be accessed directly unless through the new keyword. However, given that most object declarations are of the form

var SomeObj = function() {};
SomeObj.prototype.test = function() { return "Hello World"; }

What would be the practical differences in the above prototype assignments?

  • 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-03T09:32:32+00:00Added an answer on June 3, 2026 at 9:32 am

    Remember that a prototype is an instance of the parent type. Using child.prototype = parent.prototype would set the child’s prototype equal to the parent’s prototype, rather than an prototypical instance of the parent.

    Here’s a huge problem that arises if you use child.prototype = parent.prototype: if you try to alter the child’s prototype, you’re also altering the parent’s prototype, because they are the same object.

    Child.prototype.childOnlyValue = 5;
    // WARNING: Parent.prototype.childOnlyValue is now also 5,
    //             because Parent.prototype === Child.prototype
    

    Creating the new instance of the parent is absolutely necessary. Otherwise, you’ll have a flat prototype chain with a single shared prototype, so you’ll have problems like the one I’ve outlined above.

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

Sidebar

Related Questions

I have simple user model: var user = Backbone.Model.extend({ initialize: function(){ this.bind(change:auth, function (){
var homeView = Backbone.View.extend({ el: $(#main_container), initialize: function(){ _.bindAll(this, 'render'); }, render:function(){ $.get('/home', {},
The backbone.js annotated source describes the following piece of code var Backbone; if (typeof
Backbone.js documentation suggest loading bootstrapped models this way: <script> var Accounts = new Backbone.Collection;
In Backbone.js I can appoint where the model fetches it's data: var Book =
Code: class Session extends Backbone.Model initialize: -> @bind 'change', @save console.log 'init' class SessionList
//Model var Dog = Backbone.Model.extend({ name:'', breed:'' }); //Collection var Dogs = Backbone.Collection.extend({ model
NOTE: This question is related to CodeIgniter-RestServer When I call model.save() from backbone the
Began restructuring my Backbone app referencing this article by Bocoup: http://weblog.bocoup.com/organizing-your-backbone-js-application-with-modules I'm having trouble
Backbone's documentation states: The events property may also be defined as a function that

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.