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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:19:30+00:00 2026-05-29T05:19:30+00:00

I have a simple object (a button in Sencha Touch actually). It’s in an

  • 0

I have a simple object (a button in Sencha Touch actually). It’s in an object called ‘something.aButton()’;

This object contains a property called ‘view’ with a value of ‘home’;

Now I want to assign this to a variable, assign some new properties and pass it on.

So I do:

var c = something.aButton();

Now I assign some more stuff:

c.id = 4;
c.class = 'class';

Now the problem is that c.view is undefined unless I do:

c.view = c.view;

Which – coming from a PHP world baffles the heck out of me. I get the basics of prototypes but don’t understand how I can simply assign my object to a variable for ease of use and work from that. I don’t know all the original properties either so reassigning it like this is not possible in my code and I somehow doubt that this is the proper way.

If I dump ‘c’ to my console I see:

Ext.Object.classify.objectClass
class: "class"
id: 4
__proto__: Object
  view: 'home'
  ....
  • 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-05-29T05:19:31+00:00Added an answer on May 29, 2026 at 5:19 am

    Now I assign some more stuff:

    c.id = 4;
    c.class = 'class';
    

    I would avoid using the identifier class. It’s a reserved word in the 3rd edition of JavaScript, and in "loose" (non-strict) code in the 5th edition.

    Now the problem is that c.view is undefined unless I do:

    c.view = c.view;
    

    It’s not undefined. What you’re changing there is whather c has its own copy of the view property. If you just did console.log(c.view) you’d see its value in the console, even without doing the assignment above.

    The way prototypes work in JavaScript is that the object is backed up by the prototype in a live way. So if you take the value of view from c, and c doesn’t have its own property called view, its prototype chain is checked. But if you assign a value to view on c, then c gains a property of its own with that name, and you see it in object dumps and such.

    So here’s a simplified example:

    function Foo() {
    }
    Foo.prototype.bar = "42";
    
    var f = new Foo();
    console.log(f.bar); // "42"
    

    At the moment, our object graph looks like this:

    +-----------+      +---------------+
    |     f     |----->| Foo.prototype |
    |-----------|      |---------------|
    |           |      | bar: "42"     |
    +-----------+      +---------------+

    So there we have f, which is backed by the prototype Foo.prototype. When we ask f for the property bar, since f doesn’t have a property of its own by that name, the JavaScript engine looks to its prototype to see if it does. If so, that value is used. (And this continues if the prototype has a prototype, etc.)

    Now suppose we do this:

    f.bar = "43";
    console.log(f.bar); // "43"
    

    Because f now has its own bar property, the JavaScript engine uses the value of that property. Now our graph looks like this:

    +-----------+      +---------------+
    |     f     |----->| Foo.prototype |
    |-----------|      |---------------|
    | bar: "43" |      | bar: "42"     |
    +-----------+      +---------------+

    We can remove f‘s property:

    delete f.bar;       // `delete` removes "own" properties from objects
    console.log(f.bar); // "42"
    

    …and so retrieving bar from f once again looks to the prototype, because f doesn’t have a property called bar. We’re back to the original object graph:

    +-----------+      +---------------+
    |     f     |----->| Foo.prototype |
    |-----------|      |---------------|
    |           |      | bar: "42"     |
    +-----------+      +---------------+

    Now the fun bit: Suppose we change the prototype’s property?

    Foo.prototype.bar = "baz";
    console.log(f.bar); // "baz"
    

    Because f doesn’t have a bar property, the engine looks at the prototype. This is what I meant by it being a live system.

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

Sidebar

Related Questions

I have a simple Button control that contains an Image object as its content.
Say I have a simple object such as class Something { public int SomeInt
I have a simple button ADD And ADD_Click code is: protected void Add_Click(object sender,
I have simple mxml code <mx:DataGrid id=DGG editable=true> <mx:dataProvider> <mx:Object scheduledDate=4/1/2006/> </mx:dataProvider> </mx:DataGrid> <mx:Button
I have a simple object that get's geocoding data from the Google Maps API
I have a simple object that allows you to assign three properties (x,y,z) (lets
I have a simple JavaScript Array object containing a few numbers. [267, 306, 108]
I have a simple Dictionary(of String, Object) that I need to iterate through and
I have a simple code fragment in JS working with prototype inheritance. function object(o)
I'm relatively new to the Component Object Model specification - I have a simple

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.