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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:00:29+00:00 2026-06-03T11:00:29+00:00

I have a base view V : V = Backbone.View.extend({ initialize: function() { console.log(this.options.z);

  • 0

I have a base view V:

V = Backbone.View.extend({   
  initialize: function() {
    console.log(this.options.z);
    console.log(this.options.q);   
  }
});

extended by VV, which sets the value of a property (q: 234):

VV = V.extend({q:234});

V is further specialized to VV:

new VV({z: 123})

​
The problem is that the base type has no access to q, how can I do this?
I’m trying to understand this inheritance system, in this example
q and z are like virtual/abstract values that are to be defined in
sub classes.

http://jsfiddle.net/maxl/G8cab/

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

    When you say this:

    VV = V.extend({q: 234});
    

    you’re creating VV as “subclass” of V that will have an extra q property. The properties defined by the “class” have nothing to do with the automatic options handling from View#initialize.

    The documentation might be better if it said “creating a new instance of the View”.

    Then, when you new VV({z: 123}), that {z: 123} is passed to the view’s initialize method in its single options parameter (pre-1.1.0 Backbones automatically set this.options to the constructor’s options) the q will be in this.q so your initialize should look more like this:

    initialize: function(options) {
      console.log(options.z);
      console.log(this.q);
    }
    

    Also, if you did this:

    var VVV = VV.extend({q: 'pancakes'});
    

    you’d be replacing the default q that instances of VV get and this.q would be 'pancakes' inside initialize.

    Demo: http://jsfiddle.net/ambiguous/eqBV2/

    Using View#extend is like subclassing (or more accurately it creates a new prototypical instance) whereas new creates new objects (or copies of the prototypical instance). Of course, the class/instance language doesn’t fit the reality of JavaScript so we have to be careful not to take the terminology too seriously.

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

Sidebar

Related Questions

I have BaseView which implement UIViewController. Every view in project must implement this BaseView.
So I have a View that looks like this. //base class var SelectListView =
Assume some domain and view objects (that have no common base class) public class
I have implemented horizontal page view. One base page and three swipe pages. The
I have a base class, B, which has two constructors, one with no paremeters
I have a base UIView which takes up the entire iPhone screen when the
I have the following class that extends Backbone.View, I want all my backbone views
I'm developing a simple app with multiple views. I have a base view and
I create an application base on view based Application project . so i have
I have one base view controller contentViewController with one button the action on button

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.