... but I can't for the life of me figure it out.

I have an object that comes from an application which has a Status property, and within that property is Name and Key. So I can do things like object.Status.Name = x.

I have created another of these objects within my site and currently the value of the status field is set to 0 by default. If I want to populate the Status field to at least get a specific value in the object.Status.Name field how would I go about it?

object.Status.Name = x doesn't seem to work and instead creates object.StatusName = x when run.

Thanks in advance

Mike

Recommended Answers

All 2 Replies

Anything you can tell about the inner workings of that object?

Because if I try something like:

        var Object = function(){
            this.Status = {
                Name : "foo"
            };
        };
        var object = new Object();

        // prints foo
        console.log(object.Status.Name);

        object.Status.Name = "bar";

        // prints bar
        console.log(object.Status.Name);

Or

        var Object = function(){
            this.Status = new Status();
        };

        var Status = function(){
            this.Name = "foo";
        };

        var object = new Object();

        // prints foo
        console.log(object.Status.Name);

        object.Status.Name = "bar";

        // prints bar
        console.log(object.Status.Name);

Nothing seems the matter.

Yeah misworded it slightly I believe eventually worked out what I was trying to do with a spot of googling.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.