0
var app = {
    first_name: 'john',
    last_name: 'doe',
    full_name: this.first_name + ' ' + this.last_name
};

How to access properties within an object? I am getting undefined using this.property-name as above code.

freginold
  • 3,946
  • 3
  • 13
  • 28
zarpio
  • 10,380
  • 8
  • 58
  • 71

1 Answers1

2

Make your full_name property a method

var app = {
        first_name: 'john',
        last_name: 'doe',
        full_name:function(){
            return this.first_name + ' ' + this.last_name;
        }
    };

    alert(app.full_name());

Cheers !!!