I'm struggling to articulately explain my situation, so please excuse me if this has been addressed before.
I am seeking to specify an object in the following manner:
var foo = [
{
firstName : 'John',
lastName : 'Doe',
fullName : this.firstName + this.lastName
},
// OR
{
firstName : 'Jane',
lastName : 'Doe',
herID : Do-something with the first and last name that were just defined, such as computeCombination(firstName, lastName)
}
]
Can this type of declaration be achieved?
I must finalize the declaration of foo immediately and I cannot make alterations to the object later on. Additionally, I wish to avoid using indexes here, like accessing elements via foo[0].firstName etc..
The primary reason for my request is that I want to eliminate repetitive strings, since they are verbose. Furthermore, each object in the array may require a different logic for the final key.
Thank you