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 8845425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:44:12+00:00 2026-06-14T11:44:12+00:00

I was reading the source code of backbone today to try and learn how

  • 0

I was reading the source code of backbone today to try and learn how it works. I tried to make my own initialize method that fires when a myModel is instantiated, but it doesn’t seem to work. (alerts “default hello”)

I was thinking that when myModel was created, it would copy the “this.initialize.apply” into myModel, and it would inherit the initialize method from Model’s prototype. If myMethod didn’t have an initialize method, it would look up the chain, but if myMethod does have it, it would use that instead. From what i’m (wrongly) thinking, myModel reads the apply like “myModel.initialize.appy(this, arguments)”, but it seems to be calling Models instead.

Any idea’s on where i’m going wrong? http://jsfiddle.net/LvjpK/

function Model () {
    this.initialize.apply(this, arguments);
}


Model.prototype.initialize = function () {
    alert("Default Hello");
};


myModel = {
    initialize: function() {
        alert("Hello from myModel");
    }
};

var myModel = new Model();
  • 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-14T11:44:13+00:00Added an answer on June 14, 2026 at 11:44 am

    With your new Model() line, you’re creating a totally new object and putting a reference to it into the myModel variable.

    The initialize function that you’ve defined on myModel earlier has absolutely no relevance. It never gets into play. It just gets picked up by the garbage collector as soon as you lose a reference to it by overwriting the myModel variable with it’s new value.

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

Sidebar

Related Questions

I'm reading some source code at https://github.com/plataformatec/devise and found that line of code: class_eval
I`m reading the code of some open source project. I see that in one
While reading the source code of SortableIntField , I noticed that this class avoids
i'm reading liferay source code and found out that 2 xml files using same
I was reading through the source code for MeioUpload to make sure I understand
I'm reading the source code to the Smack api and the the method XMPPConnection#
I was reading through some source code recently that updated the code on a
I'm reading source code of FreeBSD and found that they have 2 files which
Reading through the Backbone.js source code, I saw this: validObj[attr] = void 0; What
I'm reading someone's source code for their backbone app and trying to figure out

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.