KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Possible Duplicate: Self-references in object literal declarations I have some simple objects in JS like this example: var object = { firstname : 'john', lastname : 'paul', wholename : firstname + lastname } Well this simple thing doesn't work; john and paul are undefined in wholename, so I tried to use the 'this' operator which works ONLY if I do a function (getWholeName(){return this.firstname+this.lastname} ) . But if I want to use a variable and not a function, how can I do? I also tried object.firstname + object.lastname but it doesn't work.
Tags (comma-separated)
Save Edits
Cancel