I am having a hard time describing my case, so forgive me if this is resolved before.
I want to define an object in the following way:
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)
}
]
Is this kind of declaration possible?
I need to finish the declaration of foo at once and here, I cannot make changes to the object later. Moreover, I don't want to get involved with indexes here, such as using foo[0].firstName etc..
Main reason I want this is that, I do not want to write same strings again, because it is redundant and strings are pretty lengthy. Also, each object in the array might have a different combinational logic for the last key.
Thank you